jens commited on
Commit
613f332
·
1 Parent(s): 701b155

UI flow update

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -85,23 +85,25 @@ with block:
85
  img = Image.fromarray(img)
86
  point_coords.append([x,y])
87
  point_labels.append(point_label_radio)
88
-
89
- return [unedited_image,
90
- img,
91
- point_coords,
92
- point_labels,
93
- image_edit_trigger]
 
94
 
95
  masks_annotated_image.select(on_input_image_select,
96
  [raw_image, input_image, image_edit_trigger, point_coords, point_labels, point_label_radio],
97
- [raw_image, input_image, point_coords, point_labels, image_edit_trigger], queue=False)
98
 
99
  def on_click_sam_encode_btn(inputs):
100
  print("encoding")
101
  # encode image on click
102
  sam.encode(inputs[input_image])
103
  print("encoding done")
104
- return {sam_encode_status: 'Image Encoded!'}
 
105
  sam_encode_btn.click(on_click_sam_encode_btn, components, [sam_encode_status], queue=False)
106
 
107
  def on_click_sam_dencode_btn(inputs):
 
85
  img = Image.fromarray(img)
86
  point_coords.append([x,y])
87
  point_labels.append(point_label_radio)
88
+ generated_mask, _, _ = sam.cond_pred(pts=np.array(point_coords), lbls=np.array(point_labels))
89
+ return [(img, [(generated_mask, text)]),
90
+ unedited_image,
91
+ img,
92
+ point_coords,
93
+ point_labels,
94
+ image_edit_trigger]
95
 
96
  masks_annotated_image.select(on_input_image_select,
97
  [raw_image, input_image, image_edit_trigger, point_coords, point_labels, point_label_radio],
98
+ [masks_annotated_image, raw_image, input_image, point_coords, point_labels, image_edit_trigger], queue=False)
99
 
100
  def on_click_sam_encode_btn(inputs):
101
  print("encoding")
102
  # encode image on click
103
  sam.encode(inputs[input_image])
104
  print("encoding done")
105
+ return {sam_encode_status: 'Image Encoded!',
106
+ masks_annotated_image: (inputs[input_image], [])}
107
  sam_encode_btn.click(on_click_sam_encode_btn, components, [sam_encode_status], queue=False)
108
 
109
  def on_click_sam_dencode_btn(inputs):