prithivMLmods commited on
Commit
49b03ec
·
verified ·
1 Parent(s): ec2d038

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
app.py CHANGED
@@ -292,7 +292,7 @@ def handle_example_click(file_path, query):
292
  return file_path, gr.update(value=file_path, visible=True), gr.update(visible=False), query
293
 
294
  def clear_all():
295
- return None, None, None, "### Output will be shown here", ""
296
 
297
  with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
298
  media_file_path = gr.State(None)
@@ -328,33 +328,33 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
328
  video_display = gr.Video(label="Video Preview", visible=False)
329
  gr.Markdown("Upload an image or video to begin.")
330
 
331
- # Define query_input here so gr.Examples can reference it
332
- query_input = gr.Textbox(
333
- placeholder="Enter your query here...",
334
- show_label=False,
335
- scale=4,
336
- )
337
-
338
- gr.Examples(
339
- examples=all_examples,
340
- inputs=[media_file_path, query_input], # Pass component objects
341
- outputs=[media_file_path, image_display, video_display, query_input],
342
- fn=handle_example_click,
343
- label="Examples (Click to run)",
344
- cache_examples=True
345
- )
346
-
347
  output_display = gr.Markdown(elem_classes="chat-window", value="### Output will be shown here")
348
 
349
- with gr.Row(elem_classes="input-bar", vertical=False):
 
350
  upload_btn = gr.UploadButton("📁 Add Files", file_types=["image", "video"])
351
  model_dropdown = gr.Dropdown(
352
  choices=["Nanonets-OCR-s", "MonkeyOCR-Recognition", "Thyme-RL", "Typhoon-OCR-7B", "SmolDocling-256M-preview"],
353
  label="Select Model",
354
  value="Nanonets-OCR-s"
355
  )
356
- # The query_input is already defined above, but we place it here visually
 
 
 
 
357
  submit_btn = gr.Button("▶", elem_classes="submit-button")
 
 
 
 
 
 
 
 
 
 
 
358
 
359
  # --- Event Handlers ---
360
  upload_btn.upload(
 
292
  return file_path, gr.update(value=file_path, visible=True), gr.update(visible=False), query
293
 
294
  def clear_all():
295
+ return None, gr.update(visible=False), gr.update(visible=False), "### Output will be shown here", ""
296
 
297
  with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
298
  media_file_path = gr.State(None)
 
328
  video_display = gr.Video(label="Video Preview", visible=False)
329
  gr.Markdown("Upload an image or video to begin.")
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  output_display = gr.Markdown(elem_classes="chat-window", value="### Output will be shown here")
332
 
333
+ # --- Input Bar ---
334
+ with gr.Row(elem_classes="input-bar"): # Removed vertical=False
335
  upload_btn = gr.UploadButton("📁 Add Files", file_types=["image", "video"])
336
  model_dropdown = gr.Dropdown(
337
  choices=["Nanonets-OCR-s", "MonkeyOCR-Recognition", "Thyme-RL", "Typhoon-OCR-7B", "SmolDocling-256M-preview"],
338
  label="Select Model",
339
  value="Nanonets-OCR-s"
340
  )
341
+ query_input = gr.Textbox(
342
+ placeholder="Enter your query here...",
343
+ show_label=False,
344
+ scale=4,
345
+ )
346
  submit_btn = gr.Button("▶", elem_classes="submit-button")
347
+
348
+ # --- Examples defined after all components exist ---
349
+ gr.Examples(
350
+ examples=all_examples,
351
+ inputs=[media_file_path, query_input],
352
+ outputs=[media_file_path, image_display, video_display, query_input],
353
+ fn=handle_example_click,
354
+ label="Examples (Click to run)",
355
+ cache_examples=True
356
+ )
357
+
358
 
359
  # --- Event Handlers ---
360
  upload_btn.upload(