capradeepgujaran commited on
Commit
417694d
β€’
1 Parent(s): e2d89e8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +66 -8
app.py CHANGED
@@ -145,18 +145,76 @@ def chat_about_image(message, chat_history):
145
  logger.error(f"Error during chat: {str(e)}")
146
  return "", chat_history + [(message, f"Error: {str(e)}")]
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  # Create the Gradio interface
149
- with gr.Blocks() as iface:
150
- gr.Markdown("# Construction Image Analyzer with Chat")
 
 
 
 
 
 
 
 
 
 
151
  with gr.Row():
152
  with gr.Column(scale=1):
153
- image_input = gr.Image(type="pil", label="Upload Construction Image")
154
- analyze_button = gr.Button("Analyze Image")
155
  with gr.Column(scale=2):
156
- chatbot = gr.Chatbot(label="Analysis Results and Chat")
157
-
158
- msg = gr.Textbox(label="Ask a question about the image and press Enter")
159
- clear = gr.Button("Clear Chat")
 
 
 
 
 
160
 
161
  analyze_button.click(
162
  analyze_construction_image,
 
145
  logger.error(f"Error during chat: {str(e)}")
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
+ """
190
+
191
  # Create the Gradio interface
192
+ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as iface:
193
+ gr.HTML(
194
+ """
195
+ <div class="container">
196
+ <div class="header">
197
+ <h1>πŸ—οΈ Construction Image Analyzer with AI Chat</h1>
198
+ </div>
199
+ <p class="subheader">Upload a construction site image, analyze it for issues, and chat with AI about the findings.</p>
200
+ </div>
201
+ """
202
+ )
203
+
204
  with gr.Row():
205
  with gr.Column(scale=1):
206
+ image_input = gr.Image(type="pil", label="Upload Construction Image", elem_classes="image-container")
207
+ analyze_button = gr.Button("πŸ” Analyze Image", elem_classes="analyze-button")
208
  with gr.Column(scale=2):
209
+ chatbot = gr.Chatbot(label="Analysis Results and Chat", elem_classes="chatbot")
210
+
211
+ with gr.Row():
212
+ msg = gr.Textbox(
213
+ label="Ask a question about the image",
214
+ placeholder="Type your question here and press Enter...",
215
+ show_label=False,
216
+ )
217
+ clear = gr.Button("πŸ—‘οΈ Clear Chat", elem_classes="clear-button")
218
 
219
  analyze_button.click(
220
  analyze_construction_image,