Spaces:
Runtime error
Runtime error
Fix zero point error
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import torch
|
4 |
-
import os
|
5 |
from mobile_sam import SamAutomaticMaskGenerator, SamPredictor, sam_model_registry
|
6 |
from PIL import ImageDraw
|
7 |
from utils.tools import box_prompt, format_results, point_prompt
|
@@ -109,9 +110,18 @@ def segment_with_points(
|
|
109 |
new_h = int(h * scale)
|
110 |
image = image.resize((new_w, new_h))
|
111 |
|
112 |
-
scaled_points = np.array(
|
|
|
|
|
113 |
scaled_point_label = np.array(global_point_label)
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
nd_image = np.array(image)
|
116 |
predictor.set_image(nd_image)
|
117 |
masks, scores, logits = predictor.predict(
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import gradio as gr
|
4 |
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
|
|
|
110 |
new_h = int(h * scale)
|
111 |
image = image.resize((new_w, new_h))
|
112 |
|
113 |
+
scaled_points = np.array(
|
114 |
+
[[int(x * scale) for x in point] for point in global_points]
|
115 |
+
)
|
116 |
scaled_point_label = np.array(global_point_label)
|
117 |
|
118 |
+
if scaled_points.size == 0 and scaled_point_label.size == 0:
|
119 |
+
print("No points selected")
|
120 |
+
return image, image
|
121 |
+
|
122 |
+
print(scaled_points, scaled_points is not None)
|
123 |
+
print(scaled_point_label, scaled_point_label is not None)
|
124 |
+
|
125 |
nd_image = np.array(image)
|
126 |
predictor.set_image(nd_image)
|
127 |
masks, scores, logits = predictor.predict(
|