Spaces:
Paused
Paused
Commit
·
302553c
1
Parent(s):
9863e05
Update app.py
Browse files
app.py
CHANGED
|
@@ -520,7 +520,7 @@ def run_anything_task(input_image, text_prompt, box_threshold, text_threshold,
|
|
| 520 |
"size": [size[1], size[0]], # H,W
|
| 521 |
"labels": pred_phrases,
|
| 522 |
}
|
| 523 |
-
|
| 524 |
image_with_box = plot_boxes_to_image(copy.deepcopy(image_pil), pred_dict)[0]
|
| 525 |
output_images.append(image_with_box)
|
| 526 |
|
|
@@ -550,6 +550,12 @@ def run_anything_task(input_image, text_prompt, box_threshold, text_threshold,
|
|
| 550 |
# we don't draw the background image
|
| 551 |
# plt.imshow(image)
|
| 552 |
boxes_with_labels = zip(boxes_filt, pred_phrases)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
for mask in masks:
|
| 554 |
show_mask(mask.cpu().numpy(), plt.gca(), random_color=True)
|
| 555 |
for box, label in boxes_with_labels:
|
|
@@ -568,7 +574,7 @@ def run_anything_task(input_image, text_prompt, box_threshold, text_threshold,
|
|
| 568 |
print("score: " + score)
|
| 569 |
print(box.tolist())
|
| 570 |
|
| 571 |
-
return
|
| 572 |
|
| 573 |
if __name__ == "__main__":
|
| 574 |
parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
|
|
|
|
| 520 |
"size": [size[1], size[0]], # H,W
|
| 521 |
"labels": pred_phrases,
|
| 522 |
}
|
| 523 |
+
|
| 524 |
image_with_box = plot_boxes_to_image(copy.deepcopy(image_pil), pred_dict)[0]
|
| 525 |
output_images.append(image_with_box)
|
| 526 |
|
|
|
|
| 550 |
# we don't draw the background image
|
| 551 |
# plt.imshow(image)
|
| 552 |
boxes_with_labels = zip(boxes_filt, pred_phrases)
|
| 553 |
+
debug = {
|
| 554 |
+
"thing1": boxes_filt.size(0),
|
| 555 |
+
"thing2": boxes_with_labels,
|
| 556 |
+
"thing3": pred_phrases
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
for mask in masks:
|
| 560 |
show_mask(mask.cpu().numpy(), plt.gca(), random_color=True)
|
| 561 |
for box, label in boxes_with_labels:
|
|
|
|
| 574 |
print("score: " + score)
|
| 575 |
print(box.tolist())
|
| 576 |
|
| 577 |
+
return debug, output_images, gr.Gallery.update(label='result images')
|
| 578 |
|
| 579 |
if __name__ == "__main__":
|
| 580 |
parser = argparse.ArgumentParser("Grounded SAM demo", add_help=True)
|