Spaces:
Sleeping
Sleeping
AAAAAAyq
commited on
Commit
•
d1be458
1
Parent(s):
1e39555
Update the examples for more clear visualization
Browse files- app.py +1 -1
- app_debug.py +4 -3
- gradio_cached_examples/16/log.csv +0 -2
- gradio_cached_examples/16/output/tmps67a9kx5.png +0 -0
app.py
CHANGED
@@ -157,7 +157,7 @@ def fast_show_mask_gpu(annotation, ax,
|
|
157 |
|
158 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
159 |
|
160 |
-
def predict(input, input_size=
|
161 |
input_size = int(input_size) # 确保 imgsz 是整数
|
162 |
|
163 |
# Thanks for the suggestion by hysts in HuggingFace.
|
|
|
157 |
|
158 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
159 |
|
160 |
+
def predict(input, input_size=1024, high_visual_quality=True):
|
161 |
input_size = int(input_size) # 确保 imgsz 是整数
|
162 |
|
163 |
# Thanks for the suggestion by hysts in HuggingFace.
|
app_debug.py
CHANGED
@@ -57,7 +57,7 @@ def fast_process(annotations, image, high_quality, device):
|
|
57 |
contours, _ = cv2.findContours(annotation, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
58 |
for contour in contours:
|
59 |
contour_all.append(contour)
|
60 |
-
cv2.drawContours(temp, contour_all, -1, (255, 255, 255),
|
61 |
color = np.array([0 / 255, 0 / 255, 255 / 255, 0.9])
|
62 |
contour_mask = temp / 255 * color.reshape(1, 1, -1)
|
63 |
# plt.imshow(contour_mask)
|
@@ -157,7 +157,9 @@ def fast_show_mask_gpu(annotation, ax,
|
|
157 |
|
158 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
159 |
|
160 |
-
def predict(input, input_size=
|
|
|
|
|
161 |
# Thanks for the suggestion by hysts in HuggingFace.
|
162 |
w, h = input.size
|
163 |
scale = input_size / max(w, h)
|
@@ -165,7 +167,6 @@ def predict(input, input_size=512, high_visual_quality=True):
|
|
165 |
new_h = int(h * scale)
|
166 |
input = input.resize((new_w, new_h))
|
167 |
|
168 |
-
input_size = int(input_size) # 确保 imgsz 是整数
|
169 |
results = model(input, device=device, retina_masks=True, iou=0.7, conf=0.25, imgsz=input_size)
|
170 |
fig = fast_process(annotations=results[0].masks.data,
|
171 |
image=input, high_quality=high_visual_quality, device=device)
|
|
|
57 |
contours, _ = cv2.findContours(annotation, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
58 |
for contour in contours:
|
59 |
contour_all.append(contour)
|
60 |
+
cv2.drawContours(temp, contour_all, -1, (255, 255, 255), 2)
|
61 |
color = np.array([0 / 255, 0 / 255, 255 / 255, 0.9])
|
62 |
contour_mask = temp / 255 * color.reshape(1, 1, -1)
|
63 |
# plt.imshow(contour_mask)
|
|
|
157 |
|
158 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
159 |
|
160 |
+
def predict(input, input_size=1024, high_visual_quality=True):
|
161 |
+
input_size = int(input_size) # 确保 imgsz 是整数
|
162 |
+
|
163 |
# Thanks for the suggestion by hysts in HuggingFace.
|
164 |
w, h = input.size
|
165 |
scale = input_size / max(w, h)
|
|
|
167 |
new_h = int(h * scale)
|
168 |
input = input.resize((new_w, new_h))
|
169 |
|
|
|
170 |
results = model(input, device=device, retina_masks=True, iou=0.7, conf=0.25, imgsz=input_size)
|
171 |
fig = fast_process(annotations=results[0].masks.data,
|
172 |
image=input, high_quality=high_visual_quality, device=device)
|
gradio_cached_examples/16/log.csv
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
output,flag,username,timestamp
|
2 |
-
/data1/10cls/duyinglong/sam/ultralytics/ultralytics/yolo/v8/segment/demo/FastSAM/gradio_cached_examples/16/output/tmps67a9kx5.png,,,2023-06-22 16:13:18.129722
|
|
|
|
|
|
gradio_cached_examples/16/output/tmps67a9kx5.png
DELETED
Binary file (228 kB)
|
|