Spaces:
Runtime error
Runtime error
dhkim2810
commited on
Commit
·
cabd05c
1
Parent(s):
6cf5a6c
Add debug print
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import numpy as np
|
|
| 5 |
import torch
|
| 6 |
from mobile_sam import SamAutomaticMaskGenerator, SamPredictor, sam_model_registry
|
| 7 |
from PIL import ImageDraw
|
|
|
|
| 8 |
from utils.tools import box_prompt, format_results, point_prompt
|
| 9 |
from utils.tools_gradio import fast_process
|
| 10 |
|
|
@@ -111,6 +112,8 @@ def segment_with_points(
|
|
| 111 |
global global_points
|
| 112 |
global global_point_label
|
| 113 |
|
|
|
|
|
|
|
| 114 |
input_size = int(input_size)
|
| 115 |
w, h = image.size
|
| 116 |
scale = input_size / max(w, h)
|
|
@@ -118,18 +121,21 @@ def segment_with_points(
|
|
| 118 |
new_h = int(h * scale)
|
| 119 |
image = image.resize((new_w, new_h))
|
| 120 |
|
|
|
|
|
|
|
|
|
|
| 121 |
scaled_points = np.array(
|
| 122 |
[[int(x * scale) for x in point] for point in global_points]
|
| 123 |
)
|
| 124 |
scaled_point_label = np.array(global_point_label)
|
| 125 |
|
|
|
|
|
|
|
|
|
|
| 126 |
if scaled_points.size == 0 and scaled_point_label.size == 0:
|
| 127 |
print("No points selected")
|
| 128 |
return image, image
|
| 129 |
|
| 130 |
-
print(scaled_points, scaled_points is not None)
|
| 131 |
-
print(scaled_point_label, scaled_point_label is not None)
|
| 132 |
-
|
| 133 |
nd_image = np.array(image)
|
| 134 |
predictor.set_image(nd_image)
|
| 135 |
masks, scores, logits = predictor.predict(
|
|
|
|
| 5 |
import torch
|
| 6 |
from mobile_sam import SamAutomaticMaskGenerator, SamPredictor, sam_model_registry
|
| 7 |
from PIL import ImageDraw
|
| 8 |
+
|
| 9 |
from utils.tools import box_prompt, format_results, point_prompt
|
| 10 |
from utils.tools_gradio import fast_process
|
| 11 |
|
|
|
|
| 112 |
global global_points
|
| 113 |
global global_point_label
|
| 114 |
|
| 115 |
+
print("Original Image : ", image.size)
|
| 116 |
+
|
| 117 |
input_size = int(input_size)
|
| 118 |
w, h = image.size
|
| 119 |
scale = input_size / max(w, h)
|
|
|
|
| 121 |
new_h = int(h * scale)
|
| 122 |
image = image.resize((new_w, new_h))
|
| 123 |
|
| 124 |
+
print("Scaled Image : ", image.size)
|
| 125 |
+
print("Scale : ", scale)
|
| 126 |
+
|
| 127 |
scaled_points = np.array(
|
| 128 |
[[int(x * scale) for x in point] for point in global_points]
|
| 129 |
)
|
| 130 |
scaled_point_label = np.array(global_point_label)
|
| 131 |
|
| 132 |
+
print(scaled_points, scaled_points is not None)
|
| 133 |
+
print(scaled_point_label, scaled_point_label is not None)
|
| 134 |
+
|
| 135 |
if scaled_points.size == 0 and scaled_point_label.size == 0:
|
| 136 |
print("No points selected")
|
| 137 |
return image, image
|
| 138 |
|
|
|
|
|
|
|
|
|
|
| 139 |
nd_image = np.array(image)
|
| 140 |
predictor.set_image(nd_image)
|
| 141 |
masks, scores, logits = predictor.predict(
|