Spaces:
Runtime error
Runtime error
jens
commited on
Commit
·
b3873d0
1
Parent(s):
7784349
fix
Browse files
app.py
CHANGED
|
@@ -50,6 +50,7 @@ with block:
|
|
| 50 |
reset_btn.click(on_reset_btn_click, [raw_image], [input_image, point_coords, point_labels], queue=False)
|
| 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)
|
|
@@ -68,12 +69,15 @@ with block:
|
|
| 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]))
|
| 78 |
annotated = (image, [(generated_masks[i], f'Mask {i}') for i in range(len(generated_masks))])
|
| 79 |
return {masks_annotated_image:annotated,
|
|
|
|
| 50 |
reset_btn.click(on_reset_btn_click, [raw_image], [input_image, point_coords, point_labels], queue=False)
|
| 51 |
|
| 52 |
def on_input_image_upload(input_image):
|
| 53 |
+
print("uploading")
|
| 54 |
# encode image on upload
|
| 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)
|
|
|
|
| 69 |
|
| 70 |
# event - inference
|
| 71 |
def on_click_sam_encode_btn(inputs):
|
| 72 |
+
print("encoding")
|
| 73 |
image = inputs[raw_image]
|
| 74 |
sam.encode(image)
|
| 75 |
return [None, None, None]
|
| 76 |
|
| 77 |
def on_click_sam_dencode_btn(inputs):
|
| 78 |
+
print("inferencing")
|
| 79 |
image = inputs[raw_image]
|
| 80 |
+
sam.encode(image)
|
| 81 |
generated_masks, _, _ = sam.cond_pred(pts=np.array(inputs[point_coords]), lbls=np.array(inputs[point_labels]))
|
| 82 |
annotated = (image, [(generated_masks[i], f'Mask {i}') for i in range(len(generated_masks))])
|
| 83 |
return {masks_annotated_image:annotated,
|