jens commited on
Commit
7784349
·
1 Parent(s): dd4abca
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -51,7 +51,6 @@ with block:
51
 
52
  def on_input_image_upload(input_image):
53
  # encode image on upload
54
- sam.encode(input_image)
55
  return input_image, point_coords_empty(), point_labels_empty(), None
56
  input_image.upload(on_input_image_upload, [input_image], [raw_image, point_coords, point_labels], queue=False)
57
 
@@ -67,6 +66,12 @@ with block:
67
  return img, point_coords, point_labels
68
  input_image.select(on_input_image_select, [input_image, point_coords, point_labels, point_label_radio], [input_image, point_coords, point_labels], queue=False)
69
 
 
 
 
 
 
 
70
  def on_click_sam_dencode_btn(inputs):
71
  image = inputs[raw_image]
72
  generated_masks, _, _ = sam.cond_pred(pts=np.array(inputs[point_coords]), lbls=np.array(inputs[point_labels]))
@@ -74,7 +79,7 @@ with block:
74
  return {masks_annotated_image:annotated,
75
  masks: generated_masks,
76
  cutout_idx: set()}
77
- #sam_encode_btn.click(on_click_sam_encode_btn, components, [masks_annotated_image, masks, cutout_idx], queue=True)
78
  sam_decode_btn.click(on_click_sam_dencode_btn, components, [masks_annotated_image, masks, cutout_idx], queue=True)
79
  #sam_sgmt_everything_btn.click(on_sam_sgmt_everything_click, components, [masks_annotated_image, masks, cutout_idx], queue=True)
80
 
 
51
 
52
  def on_input_image_upload(input_image):
53
  # encode image on upload
 
54
  return input_image, point_coords_empty(), point_labels_empty(), None
55
  input_image.upload(on_input_image_upload, [input_image], [raw_image, point_coords, point_labels], queue=False)
56
 
 
66
  return img, point_coords, point_labels
67
  input_image.select(on_input_image_select, [input_image, point_coords, point_labels, point_label_radio], [input_image, point_coords, point_labels], queue=False)
68
 
69
+ # event - inference
70
+ def on_click_sam_encode_btn(inputs):
71
+ image = inputs[raw_image]
72
+ sam.encode(image)
73
+ return [None, None, None]
74
+
75
  def on_click_sam_dencode_btn(inputs):
76
  image = inputs[raw_image]
77
  generated_masks, _, _ = sam.cond_pred(pts=np.array(inputs[point_coords]), lbls=np.array(inputs[point_labels]))
 
79
  return {masks_annotated_image:annotated,
80
  masks: generated_masks,
81
  cutout_idx: set()}
82
+ sam_encode_btn.click(on_click_sam_encode_btn, components, [masks_annotated_image, masks, cutout_idx], queue=True)
83
  sam_decode_btn.click(on_click_sam_dencode_btn, components, [masks_annotated_image, masks, cutout_idx], queue=True)
84
  #sam_sgmt_everything_btn.click(on_sam_sgmt_everything_click, components, [masks_annotated_image, masks, cutout_idx], queue=True)
85