merve HF staff commited on
Commit
a3e92cc
1 Parent(s): d9fe989

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -80,17 +80,23 @@ def run_grounding(input_image, grounding_caption, box_threshold, text_threshold)
80
  return image_with_box
81
 
82
  if __name__ == "__main__":
83
-
84
  parser = argparse.ArgumentParser("Grounding DINO demo", add_help=True)
85
  parser.add_argument("--debug", action="store_true", help="using debug mode")
86
  parser.add_argument("--share", action="store_true", help="share the app")
87
  args = parser.parse_args()
88
-
89
- block = gr.Blocks().queue()
 
 
 
 
 
 
90
  with block:
91
- gr.Markdown("# [Grounding DINO](https://github.com/IDEA-Research/GroundingDINO)")
92
- gr.Markdown("### Open-World Detection with Grounding DINO")
93
- gr.Markdown("Note the model runs on CPU, so it may take a while to run the model.")
94
 
95
  with gr.Row():
96
  with gr.Column():
@@ -115,6 +121,13 @@ if __name__ == "__main__":
115
 
116
  run_button.click(fn=run_grounding, inputs=[
117
  input_image, grounding_caption, box_threshold, text_threshold], outputs=[gallery])
118
-
 
 
 
 
 
 
 
119
  block.launch(share=False, show_api=False, show_error=True)
120
 
 
80
  return image_with_box
81
 
82
  if __name__ == "__main__":
83
+
84
  parser = argparse.ArgumentParser("Grounding DINO demo", add_help=True)
85
  parser.add_argument("--debug", action="store_true", help="using debug mode")
86
  parser.add_argument("--share", action="store_true", help="share the app")
87
  args = parser.parse_args()
88
+ css = """
89
+ #mkd {
90
+ height: 500px;
91
+ overflow: auto;
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>")
99
+ gr.Markdown("<h3><center>Note the model runs on CPU, so it may take a while to run the model.<h3><center>")
100
 
101
  with gr.Row():
102
  with gr.Column():
 
121
 
122
  run_button.click(fn=run_grounding, inputs=[
123
  input_image, grounding_caption, box_threshold, text_threshold], outputs=[gallery])
124
+ gr.Examples(
125
+ [["this_is_fine.png", "coffee cup", 0.25, 0.25]],
126
+ inputs = [input_image, grounding_caption, box_threshold, text_threshold],
127
+ outputs = [gallery],
128
+ fn=run_grounding,
129
+ cache_examples=True,
130
+ label='Try this example input!'
131
+ )
132
  block.launch(share=False, show_api=False, show_error=True)
133