jbilcke-hf commited on
Commit
c798217
·
1 Parent(s): 771fc5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -12
app.py CHANGED
@@ -8,9 +8,6 @@ import gradio as gr
8
 
9
  from loguru import logger
10
 
11
- # os.system("pip install diffuser==0.6.0")
12
- # os.system("pip install transformers==4.29.1")
13
-
14
  os.environ["CUDA_VISIBLE_DEVICES"] = "0"
15
 
16
  if os.environ.get('IS_MY_DEBUG') is None:
@@ -25,6 +22,7 @@ sys.path.insert(0, './GroundingDINO')
25
  import argparse
26
  import copy
27
  import re
 
28
 
29
  import numpy as np
30
  import torch
@@ -570,10 +568,10 @@ def run_anything_task(input_image, text_prompt, box_threshold, text_threshold,
570
  print("color: " + str(color.tolist()))
571
  item = {
572
  "id": i,
573
- "box": str(boxes_filt[i].tolist()),
574
  "label": label,
575
  "score": score,
576
- "color": str(color.tolist())
577
  }
578
  results.append(item)
579
 
@@ -586,10 +584,7 @@ def run_anything_task(input_image, text_prompt, box_threshold, text_threshold,
586
  os.remove(image_path)
587
  output_images.append(segment_image_result)
588
 
589
- debug = {
590
- "results": results
591
- }
592
- return debug, output_images, gr.Gallery.update(label='result images')
593
 
594
  if __name__ == "__main__":
595
  parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
@@ -632,8 +627,6 @@ if __name__ == "__main__":
632
  ).style(preview=True, columns=[5], object_fit="scale-down", height="auto")
633
 
634
  run_button.click(fn=run_anything_task, inputs=[
635
- input_image, text_prompt, box_threshold, text_threshold, iou_threshold], outputs=[gr.JSON(), image_gallery, image_gallery], show_progress=True, queue=True)
636
-
637
 
638
- computer_info()
639
  block.launch(server_name='0.0.0.0', debug=args.debug, share=args.share)
 
8
 
9
  from loguru import logger
10
 
 
 
 
11
  os.environ["CUDA_VISIBLE_DEVICES"] = "0"
12
 
13
  if os.environ.get('IS_MY_DEBUG') is None:
 
22
  import argparse
23
  import copy
24
  import re
25
+ import json
26
 
27
  import numpy as np
28
  import torch
 
568
  print("color: " + str(color.tolist()))
569
  item = {
570
  "id": i,
571
+ "box": boxes_filt[i].tolist(),
572
  "label": label,
573
  "score": score,
574
+ "color": color.tolist(),
575
  }
576
  results.append(item)
577
 
 
584
  os.remove(image_path)
585
  output_images.append(segment_image_result)
586
 
587
+ return json.dumps(results), output_images, gr.Gallery.update(label='result images')
 
 
 
588
 
589
  if __name__ == "__main__":
590
  parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
 
627
  ).style(preview=True, columns=[5], object_fit="scale-down", height="auto")
628
 
629
  run_button.click(fn=run_anything_task, inputs=[
630
+ input_image, text_prompt, box_threshold, text_threshold, iou_threshold], outputs=[gr.Textbox(), image_gallery, image_gallery], show_progress=True, queue=True)
 
631
 
 
632
  block.launch(server_name='0.0.0.0', debug=args.debug, share=args.share)