Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -192,7 +192,7 @@ def segment_with_points(
|
|
| 192 |
output_img = (output_img * 0.7 + color * 0.3).astype(np.uint8)
|
| 193 |
|
| 194 |
output_img = Image.fromarray(output_img)
|
| 195 |
-
return
|
| 196 |
|
| 197 |
|
| 198 |
def segment_with_bbox(
|
|
@@ -278,7 +278,7 @@ def extract_img_feat(img, img_state):
|
|
| 278 |
return None, None, "CUDA OOM, please try again later."
|
| 279 |
else:
|
| 280 |
raise
|
| 281 |
-
return
|
| 282 |
|
| 283 |
|
| 284 |
def clear_everything(img_state):
|
|
@@ -325,7 +325,7 @@ def register_point_mode():
|
|
| 325 |
gr.Examples(
|
| 326 |
examples=examples,
|
| 327 |
inputs=[cond_img_p, img_state_points],
|
| 328 |
-
outputs=[
|
| 329 |
examples_per_page=12,
|
| 330 |
fn=extract_img_feat,
|
| 331 |
run_on_click=True,
|
|
@@ -356,7 +356,7 @@ def register_point_mode():
|
|
| 356 |
gr.Examples(
|
| 357 |
examples=examples,
|
| 358 |
inputs=[cond_img_bbox, img_state_bbox],
|
| 359 |
-
outputs=[
|
| 360 |
examples_per_page=12,
|
| 361 |
fn=extract_img_feat,
|
| 362 |
run_on_click=True,
|
|
@@ -367,12 +367,12 @@ def register_point_mode():
|
|
| 367 |
cond_img_p.upload(
|
| 368 |
extract_img_feat,
|
| 369 |
[cond_img_p, img_state_points],
|
| 370 |
-
outputs=[
|
| 371 |
)
|
| 372 |
cond_img_bbox.upload(
|
| 373 |
extract_img_feat,
|
| 374 |
[cond_img_bbox, img_state_bbox],
|
| 375 |
-
outputs=[
|
| 376 |
)
|
| 377 |
|
| 378 |
# get user added points
|
|
@@ -383,7 +383,7 @@ def register_point_mode():
|
|
| 383 |
).then(
|
| 384 |
segment_with_points,
|
| 385 |
inputs=[cond_img_p, img_state_points],
|
| 386 |
-
outputs=[
|
| 387 |
)
|
| 388 |
cond_img_bbox.select(
|
| 389 |
get_bbox_with_draw,
|
|
|
|
| 192 |
output_img = (output_img * 0.7 + color * 0.3).astype(np.uint8)
|
| 193 |
|
| 194 |
output_img = Image.fromarray(output_img)
|
| 195 |
+
return image, output_img, cls_info
|
| 196 |
|
| 197 |
|
| 198 |
def segment_with_bbox(
|
|
|
|
| 278 |
return None, None, "CUDA OOM, please try again later."
|
| 279 |
else:
|
| 280 |
raise
|
| 281 |
+
return img, None, "Please try to click something."
|
| 282 |
|
| 283 |
|
| 284 |
def clear_everything(img_state):
|
|
|
|
| 325 |
gr.Examples(
|
| 326 |
examples=examples,
|
| 327 |
inputs=[cond_img_p, img_state_points],
|
| 328 |
+
outputs=[cond_img_p, segm_img_p, cls_info],
|
| 329 |
examples_per_page=12,
|
| 330 |
fn=extract_img_feat,
|
| 331 |
run_on_click=True,
|
|
|
|
| 356 |
gr.Examples(
|
| 357 |
examples=examples,
|
| 358 |
inputs=[cond_img_bbox, img_state_bbox],
|
| 359 |
+
outputs=[cond_img_bbox, segm_img_bbox, cls_info_bbox],
|
| 360 |
examples_per_page=12,
|
| 361 |
fn=extract_img_feat,
|
| 362 |
run_on_click=True,
|
|
|
|
| 367 |
cond_img_p.upload(
|
| 368 |
extract_img_feat,
|
| 369 |
[cond_img_p, img_state_points],
|
| 370 |
+
outputs=[cond_img_p, segm_img_p, cls_info]
|
| 371 |
)
|
| 372 |
cond_img_bbox.upload(
|
| 373 |
extract_img_feat,
|
| 374 |
[cond_img_bbox, img_state_bbox],
|
| 375 |
+
outputs=[cond_img_bbox, segm_img_bbox, cls_info]
|
| 376 |
)
|
| 377 |
|
| 378 |
# get user added points
|
|
|
|
| 383 |
).then(
|
| 384 |
segment_with_points,
|
| 385 |
inputs=[cond_img_p, img_state_points],
|
| 386 |
+
outputs=[cond_img_p, segm_img_p, cls_info]
|
| 387 |
)
|
| 388 |
cond_img_bbox.select(
|
| 389 |
get_bbox_with_draw,
|