jesoteric commited on
Commit
e87d359
·
1 Parent(s): abec3b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -40
app.py CHANGED
@@ -288,45 +288,22 @@ def run_grounded_sam(input_image, text_prompt, task_type, inpaint_prompt, box_th
288
 
289
  if __name__ == "__main__":
290
  parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
291
- parser.add_argument("--debug", action="store_true",
292
- help="using debug mode")
293
- parser.add_argument("--share", action="store_true", help="share the app")
294
- parser.add_argument('--no-gradio-queue', action="store_true",
295
- help='path to the SAM checkpoint')
296
  args = parser.parse_args()
297
 
298
- print(args)
299
-
300
- block = gr.Blocks()
301
- if not args.no_gradio_queue:
302
- block = block.queue()
303
-
304
- with block:
305
- with gr.Row():
306
- with gr.Column():
307
- input_image = gr.Image(
308
- source='upload', type="pil", value="demo1.jpg")
309
- task_type = gr.Dropdown(
310
- ["det", "seg", "inpainting", "automatic"], value="seg", label="task_type")
311
- text_prompt = gr.Textbox(label="Text Prompt", placeholder="bear . beach .")
312
- inpaint_prompt = gr.Textbox(label="Inpaint Prompt", placeholder="A dinosaur, detailed, 4K.")
313
- run_button = gr.Button(label="Run")
314
- with gr.Accordion("Advanced options", open=False):
315
- box_threshold = gr.Slider(
316
- label="Box Threshold", minimum=0.0, maximum=1.0, value=0.3, step=0.001
317
- )
318
- text_threshold = gr.Slider(
319
- label="Text Threshold", minimum=0.0, maximum=1.0, value=0.25, step=0.001
320
- )
321
- iou_threshold = gr.Slider(
322
- label="IOU Threshold", minimum=0.0, maximum=1.0, value=0.8, step=0.001
323
- )
324
- inpaint_mode = gr.Dropdown(
325
- ["merge", "first"], value="merge", label="inpaint_mode")
326
-
327
- with gr.Column():
328
- gallery = gr.Gallery(
329
- show_label=False, elem_id="gallery"
330
- ).style(preview=True, grid=2, object_fit="scale-down")
331
-
332
- block.launch(debug=args.debug, share=args.share, show_error=True)
 
288
 
289
  if __name__ == "__main__":
290
  parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
291
+ parser.add_argument("--debug", action="store_true", help="using debug mode")
 
 
 
 
292
  args = parser.parse_args()
293
 
294
+ inputs = [
295
+ gr.inputs.Image(type="pil", label="Input Image"),
296
+ gr.inputs.Dropdown(["det", "seg", "inpainting", "automatic"], label="Task Type"),
297
+ gr.inputs.Textbox(label="Text Prompt", placeholder="bear . beach ."),
298
+ gr.inputs.Textbox(label="Inpaint Prompt", placeholder="A dinosaur, detailed, 4K."),
299
+ gr.inputs.Slider(label="Box Threshold", minimum=0.0, maximum=1.0, value=0.3, step=0.001),
300
+ gr.inputs.Slider(label="Text Threshold", minimum=0.0, maximum=1.0, value=0.25, step=0.001),
301
+ gr.inputs.Slider(label="IOU Threshold", minimum=0.0, maximum=1.0, value=0.8, step=0.001),
302
+ gr.inputs.Dropdown(["merge", "first"], label="Inpaint Mode")
303
+ ]
304
+
305
+ outputs = gr.outputs.Image(type="pil", label="Output Image")
306
+
307
+ iface = gr.Interface(run_demo, inputs, outputs, title="Grounded SAM Demo")
308
+
309
+ iface.launch(debug=args.debug)