Chamin09 commited on
Commit
24abe06
·
verified ·
1 Parent(s): 5761d1b

Update interface/app.py

Browse files
Files changed (1) hide show
  1. interface/app.py +60 -7
interface/app.py CHANGED
@@ -144,23 +144,32 @@ def create_interface():
144
  # inputs=[processing_status],
145
  # outputs=[results_box, selected_images, confidence_scores, processing_status]
146
  # )
 
 
 
 
 
147
  # Update the click handler
 
148
  submit_btn.click(
149
- # First clear/reset outputs
150
  fn=lambda: (
151
- "Processing...", # for results_box
152
- None, # for selected_images
153
- None, # for confidence_scores
154
- {"status": "processing"} # for processing_status
 
155
  ),
156
  inputs=None,
157
  outputs=[
 
158
  results_box,
159
  selected_images,
160
  confidence_scores,
161
  processing_status
162
  ]
163
- ).then( # Then process inputs
 
164
  fn=handler.process_inputs,
165
  inputs=[
166
  query,
@@ -174,8 +183,52 @@ def create_interface():
174
  selected_images,
175
  confidence_scores,
176
  processing_status
177
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
  return app
181
 
 
144
  # inputs=[processing_status],
145
  # outputs=[results_box, selected_images, confidence_scores, processing_status]
146
  # )
147
+
148
+
149
+ progress_message = gr.Markdown("Ready to analyze...")
150
+
151
+
152
  # Update the click handler
153
+
154
  submit_btn.click(
155
+ # First update UI to show processing state
156
  fn=lambda: (
157
+ gr.update(visible=True, value="Processing your request..."), # progress message
158
+ gr.update(visible=False), # results
159
+ gr.update(visible=False), # images
160
+ gr.update(visible=False), # scores
161
+ gr.update(visible=True, value={"status": "started", "step": "initializing"}) # status
162
  ),
163
  inputs=None,
164
  outputs=[
165
+ progress_message,
166
  results_box,
167
  selected_images,
168
  confidence_scores,
169
  processing_status
170
  ]
171
+ ).then(
172
+ # Process inputs
173
  fn=handler.process_inputs,
174
  inputs=[
175
  query,
 
183
  selected_images,
184
  confidence_scores,
185
  processing_status
186
+ ],
187
+ show_progress="full" # Show gradio's built-in progress
188
+ ).then(
189
+ # Update UI after processing
190
+ fn=lambda: gr.update(visible=True, value="✅ Analysis complete!"),
191
+ inputs=None,
192
+ outputs=progress_message
193
+ )
194
+
195
+ # Add error handling feedback
196
+ progress_message.change(
197
+ fn=lambda x: gr.update(visible=True) if "Error" in str(x) else gr.update(visible=False),
198
+ inputs=[progress_message],
199
+ outputs=[progress_message]
200
  )
201
+ # submit_btn.click(
202
+ # # First clear/reset outputs
203
+ # fn=lambda: (
204
+ # "Processing...", # for results_box
205
+ # None, # for selected_images
206
+ # None, # for confidence_scores
207
+ # {"status": "processing"} # for processing_status
208
+ # ),
209
+ # inputs=None,
210
+ # outputs=[
211
+ # results_box,
212
+ # selected_images,
213
+ # confidence_scores,
214
+ # processing_status
215
+ # ]
216
+ # ).then( # Then process inputs
217
+ # fn=handler.process_inputs,
218
+ # inputs=[
219
+ # query,
220
+ # constraints,
221
+ # images,
222
+ # top_k,
223
+ # report_format
224
+ # ],
225
+ # outputs=[
226
+ # results_box,
227
+ # selected_images,
228
+ # confidence_scores,
229
+ # processing_status
230
+ # ]
231
+ # )
232
 
233
  return app
234