capradeepgujaran commited on
Commit
e8dabed
β€’
1 Parent(s): 74cd746

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -51
app.py CHANGED
@@ -146,51 +146,18 @@ def chat_about_image(message, chat_history):
146
  return "", chat_history + [(message, f"Error: {str(e)}")]
147
 
148
 
 
149
  custom_css = """
150
- .container {
151
- max-width: 1000px;
152
- margin: auto;
153
- padding-top: 1.5rem;
154
- }
155
- .header {
156
- text-align: center;
157
- margin-bottom: 2rem;
158
- }
159
- .header h1 {
160
- color: #2c3e50;
161
- font-size: 2.5rem;
162
- }
163
- .subheader {
164
- color: #34495e;
165
- font-size: 1.2rem;
166
- margin-bottom: 2rem;
167
- }
168
- .image-container {
169
- border: 2px dashed #3498db;
170
- border-radius: 10px;
171
- padding: 1rem;
172
- text-align: center;
173
- }
174
- .analyze-button {
175
- background-color: #2ecc71 !important;
176
- color: white !important;
177
- }
178
- .clear-button {
179
- background-color: #e74c3c !important;
180
- color: white !important;
181
- }
182
- .chatbot {
183
- border: 1px solid #bdc3c7;
184
- border-radius: 10px;
185
- padding: 1rem;
186
- height: 400px;
187
- overflow-y: auto;
188
- }
189
- .chat-input {
190
- border: 1px solid #bdc3c7;
191
- border-radius: 5px;
192
- padding: 0.5rem;
193
- }
194
  """
195
 
196
  # Create the Gradio interface
@@ -199,23 +166,23 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
199
  """
200
  <div class="container">
201
  <div class="header">
202
- <h1>πŸ—οΈ Construction Image Analyzer with AI Chat</h1>
203
  </div>
204
- <p class="subheader">Upload a construction site image, analyze it for issues, and chat with AI about the findings.</p>
205
  </div>
206
  """
207
  )
208
 
209
  with gr.Row():
210
  with gr.Column(scale=1):
211
- image_input = gr.Image(type="pil", label="Upload Construction Image", elem_classes="image-container")
212
- analyze_button = gr.Button("πŸ” Analyze Image", elem_classes="analyze-button")
213
  with gr.Column(scale=2):
214
- chatbot = gr.Chatbot(label="Analysis Results and Chat", elem_classes="chatbot")
215
  with gr.Row():
216
  msg = gr.Textbox(
217
- label="Ask a question about the image",
218
- placeholder="Type your question here and press Enter...",
219
  show_label=False,
220
  elem_classes="chat-input"
221
  )
@@ -230,6 +197,12 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
230
  msg.submit(chat_about_image, [msg, chatbot], [msg, chatbot])
231
  clear.click(lambda: None, None, chatbot, queue=False)
232
 
 
 
 
 
 
 
233
  # Launch the app
234
  if __name__ == "__main__":
235
  iface.launch(debug=True)
 
146
  return "", chat_history + [(message, f"Error: {str(e)}")]
147
 
148
 
149
+ # Custom CSS for improved styling
150
  custom_css = """
151
+ .container { max-width: 1000px; margin: auto; padding-top: 1.5rem; }
152
+ .header { text-align: center; margin-bottom: 2rem; }
153
+ .header h1 { color: #2c3e50; font-size: 2.5rem; }
154
+ .subheader { color: #34495e; font-size: 1.2rem; margin-bottom: 2rem; }
155
+ .image-container { border: 2px dashed #3498db; border-radius: 10px; padding: 1rem; text-align: center; }
156
+ .analyze-button { background-color: #2ecc71 !important; color: white !important; }
157
+ .clear-button { background-color: #e74c3c !important; color: white !important; }
158
+ .chatbot { border: 1px solid #bdc3c7; border-radius: 10px; padding: 1rem; height: 400px; overflow-y: auto; }
159
+ .chat-input { border: 1px solid #bdc3c7; border-radius: 5px; padding: 0.5rem; }
160
+ .groq-badge { position: fixed; bottom: 10px; right: 10px; background-color: #f39c12; color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  """
162
 
163
  # Create the Gradio interface
 
166
  """
167
  <div class="container">
168
  <div class="header">
169
+ <h1>πŸ—οΈ Construction Site Safety Analyzer</h1>
170
  </div>
171
+ <p class="subheader">Enhance workplace safety and compliance with AI-powered image analysis and expert chat assistance.</p>
172
  </div>
173
  """
174
  )
175
 
176
  with gr.Row():
177
  with gr.Column(scale=1):
178
+ image_input = gr.Image(type="pil", label="Upload Construction Site Image", elem_classes="image-container")
179
+ analyze_button = gr.Button("πŸ” Analyze Safety Hazards", elem_classes="analyze-button")
180
  with gr.Column(scale=2):
181
+ chatbot = gr.Chatbot(label="Safety Analysis Results and Expert Chat", elem_classes="chatbot")
182
  with gr.Row():
183
  msg = gr.Textbox(
184
+ label="Ask about safety measures or regulations",
185
+ placeholder="E.g., 'What OSHA guidelines apply to this hazard?'",
186
  show_label=False,
187
  elem_classes="chat-input"
188
  )
 
197
  msg.submit(chat_about_image, [msg, chatbot], [msg, chatbot])
198
  clear.click(lambda: None, None, chatbot, queue=False)
199
 
200
+ gr.HTML(
201
+ """
202
+ <div class="groq-badge">Powered by Groq</div>
203
+ """
204
+ )
205
+
206
  # Launch the app
207
  if __name__ == "__main__":
208
  iface.launch(debug=True)