KurtLin commited on
Commit
4068132
·
1 Parent(s): 799e107

Initial Commit

Browse files
Files changed (1) hide show
  1. app.py +35 -14
app.py CHANGED
@@ -35,13 +35,22 @@ def inference(image, input_label, model_choice):
35
  point_labels=input_label,
36
  multimask_output=True,
37
  )
38
- mask = masks[0]
39
- print(scores)
40
- score = scores[0]
41
- image2 = image.copy()
42
- image2[mask, 0] = 255
43
- image2[y-10:y+10, x-10:x+10, 2] = 255
44
- return f"{score}", image2
 
 
 
 
 
 
 
 
 
45
 
46
 
47
  my_app = gr.Blocks()
@@ -55,13 +64,21 @@ with my_app:
55
  value='./images/truck.jpg').style(height=500, width=1000)
56
  with gr.Row():
57
  coords = gr.Label(label="Image Coordinate")
58
- with gr.Column():
59
- model_choice = gr.Dropdown(['ViT-base', 'ViT-large', 'ViT-huge'], label='Model Backbone')
60
- infer = gr.Button(label="Segment")
61
  with gr.Row():
62
- score = gr.Label(label="Mask Confidence")
63
  with gr.Row():
64
- img_output = gr.Image(label="Output Mask").style(height=500, width=1000)
 
 
 
 
 
 
 
 
 
 
65
 
66
  img_source.select(get_coords, [], coords)
67
  infer.click(
@@ -72,8 +89,12 @@ with my_app:
72
  model_choice
73
  ],
74
  [
75
- score,
76
- img_output
 
 
 
 
77
  ]
78
  )
79
 
 
35
  point_labels=input_label,
36
  multimask_output=True,
37
  )
38
+ mask1 = masks[0]
39
+ score1 = scores[0]
40
+ img1 = image.copy()
41
+ img1[mask1, 0] = 255
42
+ img1[y-10:y+10, x-10:x+10, 2] = 255
43
+ mask2 = masks[1]
44
+ score2 = scores[1]
45
+ img2 = image.copy()
46
+ img2[mask2, 0] = 255
47
+ img2[y-10:y+10, x-10:x+10, 2] = 255
48
+ mask3 = masks[2]
49
+ score3 = scores[2]
50
+ img3 = image.copy()
51
+ img3[mask3, 0] = 255
52
+ img3[y-10:y+10, x-10:x+10, 2] = 255
53
+ return f"{score1}", img1, f"{score2}", img2, f"{score3}", img3
54
 
55
 
56
  my_app = gr.Blocks()
 
64
  value='./images/truck.jpg').style(height=500, width=1000)
65
  with gr.Row():
66
  coords = gr.Label(label="Image Coordinate")
67
+ model_choice = gr.Dropdown(['ViT-base', 'ViT-large', 'ViT-huge'], label='Model Backbone')
 
 
68
  with gr.Row():
69
+ infer = gr.Button(label="Segment")
70
  with gr.Row():
71
+ score1 = gr.Label(label="Mask 1 Confidence")
72
+ with gr.Row():
73
+ img_output1 = gr.Image(label="Output Mask 1").style(height=500, width=1000)
74
+ with gr.Row():
75
+ score2 = gr.Label(label="Mask 2 Confidence")
76
+ with gr.Row():
77
+ img_output2 = gr.Image(label="Output Mask 2").style(height=500, width=1000)
78
+ with gr.Row():
79
+ score3 = gr.Label(label="Mask 3 Confidence")
80
+ with gr.Row():
81
+ img_output3 = gr.Image(label="Output Mask 3").style(height=500, width=1000)
82
 
83
  img_source.select(get_coords, [], coords)
84
  infer.click(
 
89
  model_choice
90
  ],
91
  [
92
+ score1,
93
+ img_output1,
94
+ score2,
95
+ img_output2,
96
+ score3,
97
+ img_output3,
98
  ]
99
  )
100