Delete app.py
Browse files
app.py
DELETED
|
@@ -1,22 +0,0 @@
|
|
| 1 |
-
from segment_anything import sam_model_registry
|
| 2 |
-
import torch
|
| 3 |
-
import cv2
|
| 4 |
-
import numpy as np
|
| 5 |
-
from utils import select_random_points, save_masks
|
| 6 |
-
|
| 7 |
-
# โหลดโมเดล SAM-Med2D
|
| 8 |
-
sam = sam_model_registry("vit_b", "pretrain_model/sam-med2d_b.pth")
|
| 9 |
-
sam.eval()
|
| 10 |
-
|
| 11 |
-
# โหลดภาพที่ต้องการแบ่งส่วน
|
| 12 |
-
image = cv2.imread("path_to_image.png")
|
| 13 |
-
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 14 |
-
|
| 15 |
-
# เลือกจุดที่ต้องการแบ่งส่วน
|
| 16 |
-
point = select_random_points(image_rgb)
|
| 17 |
-
|
| 18 |
-
# ประมวลผลและแบ่งส่วนภาพ
|
| 19 |
-
masks, scores = sam.predict(image_rgb, point)
|
| 20 |
-
|
| 21 |
-
# บันทึกมาสก์ที่ได้
|
| 22 |
-
save_masks(masks)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|