Omnibus commited on
Commit
b2c1780
β€’
1 Parent(s): 8950622

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -8
app.py CHANGED
@@ -7,7 +7,22 @@ from transformers import pipeline
7
  import gradio as gr
8
  import os
9
 
10
- model = pipeline("image-segmentation", model="facebook/detr-resnet-50-panoptic")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  pred = []
13
 
@@ -24,9 +39,12 @@ def image_objects(image):
24
  pred = model(image)
25
  pred_object_list = [str(i)+'_'+x['label'] for i, x in enumerate(pred)]
26
  return gr.Dropdown.update(choices = pred_object_list, interactive = True)
 
 
27
 
28
- def get_seg(image):
29
  image = img_resize(image)
 
30
  pred = model(image)
31
  pred_object_list = [str(i)+'_'+x['label'] for i, x in enumerate(pred)]
32
  seg_box=[]
@@ -60,17 +78,16 @@ with app:
60
  """)
61
  with gr.Row():
62
  with gr.Column():
63
-
64
  image_input = gr.Image(label="Input Image",type="pil")
65
- with gr.Row():
66
  with gr.Column():
67
- object_output = gr.Dropdown(label="Objects")
68
-
69
  with gr.Row():
70
  with gr.Column():
71
- gal1=gr.Gallery(type="filepath").style(grid=4)
72
 
73
- image_input.change(get_seg, inputs=[image_input], outputs=[gal1,object_output])
 
74
 
75
 
76
 
 
7
  import gradio as gr
8
  import os
9
 
10
+ models1 = [
11
+ "facebook/detr-resnet-50-panoptic",
12
+ "CIDAS/clipseg-rd64-refined",
13
+ "facebook/maskformer-swin-large-ade",
14
+ "nvidia/segformer-b1-finetuned-cityscapes-1024-1024",
15
+ ]
16
+ current_model = models1[0]
17
+
18
+ models=[
19
+ pipeline("image-segmentation", model="facebook/detr-resnet-50-panoptic"),
20
+ pipeline("image-segmentation", model="facebook/maskformer-swin-large-ade"),
21
+ pipeline("image-segmentation", model="CIDAS/clipseg-rd64-refined"),
22
+ pipeline("image-segmentation", model="nvidia/segformer-b1-finetuned-cityscapes-1024-1024"),
23
+ ]
24
+
25
+ #model = pipeline("image-segmentation", model="facebook/detr-resnet-50-panoptic")
26
 
27
  pred = []
28
 
 
39
  pred = model(image)
40
  pred_object_list = [str(i)+'_'+x['label'] for i, x in enumerate(pred)]
41
  return gr.Dropdown.update(choices = pred_object_list, interactive = True)
42
+
43
+
44
 
45
+ def get_seg(image, model_choice):
46
  image = img_resize(image)
47
+ model = models[model_choice]
48
  pred = model(image)
49
  pred_object_list = [str(i)+'_'+x['label'] for i, x in enumerate(pred)]
50
  seg_box=[]
 
78
  """)
79
  with gr.Row():
80
  with gr.Column():
 
81
  image_input = gr.Image(label="Input Image",type="pil")
82
+ model_name = gr.Dropdown(show_label=False, choices=[m for m in models], type="index", value=current_model, interactive=True)
83
  with gr.Column():
84
+ gal1=gr.Gallery(type="filepath").style(grid=6)
 
85
  with gr.Row():
86
  with gr.Column():
87
+ object_output = gr.Dropdown(label="Objects")
88
 
89
+
90
+ image_input.change(get_seg, inputs=[image_input, model_name], outputs=[gal1,object_output])
91
 
92
 
93