scaneat_yolov8/
โโโ train/
โ โโโ images/ (621์ฅ)
โ โโโ labels/ (CVAT ๋ผ๋ฒจ๋ง)
โโโ valid/ (38์ฅ)
โโโ test/ (์๋)
โโโ data.yaml
# Box โ Polygon ๋ณํ (Segmentation์ฉ)
def fix_all_labels_to_polygon(label_dir):
for txt_file in Path(label_dir).glob('*.txt'):
# Box format (cx, cy, w, h) โ Polygon (4์ )
if len(coords) == 4:
x1 = cx - w/2
y1 = cy - h/2
x2 = cx + w/2
y2 = cy + h/2
# 4์ polygon์ผ๋ก ๋ณํ
polygon = f"{cls} {x1} {y1} {x2} {y1} {x2} {y2} {x1} {y2}"
ํต์ฌ: YOLOv8-seg๋ Polygon ํ์! Box๋ง ์์ผ๋ฉด ๋ณํ ํ์
from ultralytics import YOLO
model = YOLO('yolov8s-seg.pt')
results = model.train(
data='data.yaml',
epochs=100,
imgsz=640,
batch=8,
device=0, # GPU
# ๊ธฐ๋ณธ ์ฆ๊ฐ
degrees=10.0,
fliplr=0.5,
mosaic=0.0, # ์ฒ์์ ๋
patience=20,
)