markany-yhkwon commited on
Commit
fbd28e2
·
1 Parent(s): 1af850d
Files changed (1) hide show
  1. app.py +18 -20
app.py CHANGED
@@ -8,6 +8,9 @@ from PIL import Image
8
  import numpy as np
9
  from pathlib import Path
10
  import gradio as gr
 
 
 
11
 
12
  import warnings
13
 
@@ -92,7 +95,8 @@ if __name__ == "__main__":
92
  border: 1px solid #ccc;
93
  }
94
  """
95
- block = gr.Blocks(css=css).queue()
 
96
  with block:
97
  gr.Markdown("<h1><center>Grounding DINO<h1><center>")
98
  gr.Markdown("<h3><center>Open-World Detection with <a href='https://github.com/IDEA-Research/GroundingDINO'>Grounding DINO</a><h3><center>")
@@ -100,29 +104,23 @@ if __name__ == "__main__":
100
 
101
  with gr.Row():
102
  with gr.Column():
103
- input_image = gr.Image(type="pil")
104
- grounding_caption = gr.Textbox("Detection Prompt")
105
- run_button = gr.Button("Run")
106
- with gr.Accordion("Advanced options", open=False):
107
- box_threshold = gr.Slider(
108
- minimum=0.0, maximum=1.0, value=0.25, step=0.001, label="Box Threshold"
109
- )
110
- text_threshold = gr.Slider(
111
- minimum=0.0, maximum=1.0, value=0.25, step=0.001, label="Text Threshold"
112
- )
113
 
114
  with gr.Column():
115
- gallery = gr.Image(
116
  type="pil"
117
  ).scale(full_width=True)
118
 
119
  run_button.click(fn=run_grounding, inputs=[
120
  input_image, grounding_caption, box_threshold, text_threshold], outputs=[gallery])
121
- gr.Examples(
122
- examples=[["this_is_fine.png", "coffee cup", 0.25, 0.25]],
123
- inputs=[input_image, grounding_caption, box_threshold, text_threshold],
124
- outputs=[gallery],
125
- fn=run_grounding,
126
- cache_examples=True
127
- )
128
- block.launch(share=False, show_api=False, show_error=True)
 
8
  import numpy as np
9
  from pathlib import Path
10
  import gradio as gr
11
+ from gradio.inputs import Image as GradioImage
12
+ from gradio.outputs import Image as GradioOutputImage
13
+ from gradio.components import Textbox, Button, Slider
14
 
15
  import warnings
16
 
 
95
  border: 1px solid #ccc;
96
  }
97
  """
98
+ # Using a simpler block creation method
99
+ block = gr.Blocks()
100
  with block:
101
  gr.Markdown("<h1><center>Grounding DINO<h1><center>")
102
  gr.Markdown("<h3><center>Open-World Detection with <a href='https://github.com/IDEA-Research/GroundingDINO'>Grounding DINO</a><h3><center>")
 
104
 
105
  with gr.Row():
106
  with gr.Column():
107
+ input_image = GradioImage(type="pil")
108
+ grounding_caption = Textbox("Detection Prompt")
109
+ run_button = Button("Run")
110
+ # Advanced options in a collapsible section
111
+ box_threshold = Slider(
112
+ minimum=0.0, maximum=1.0, value=0.25, step=0.001, label="Box Threshold"
113
+ )
114
+ text_threshold = Slider(
115
+ minimum=0.0, maximum=1.0, value=0.25, step=0.001, label="Text Threshold"
116
+ )
117
 
118
  with gr.Column():
119
+ gallery = GradioOutputImage(
120
  type="pil"
121
  ).scale(full_width=True)
122
 
123
  run_button.click(fn=run_grounding, inputs=[
124
  input_image, grounding_caption, box_threshold, text_threshold], outputs=[gallery])
125
+ # Example setup removed - older versions may not support Examples component
126
+ block.launch(share=False, show_api=False, show_error=True)