Views
No views yet

1from ultralytics import YOLO
2
3# Use pretrained Yolo segmentation model
4model = YOLO('yolov8x.pt')
5
6# Path to .yaml file where data location and object classes are defined
7yaml_path = 'intersections.yaml'
8
9# Start model training with the defined parameters
10model.train(data=yaml_path, name='model_name', epochs=100, imgsz=2560, max_det=500, workers=4, optimizer='AdamW',
11 lr0=0.00098, lrf=0.01285, momentum=0.90725, weight_decay=0.00061, warmup_epochs=3.91327, warmup_momentum=0.72051,
12 box=9.34214, cls=0.34133, dfl=1.83008, hsv_h=0.01126, hsv_s=0.84221, hsv_v=0.435, translate=0.11692,
13 scale=0.45713, fliplr=0.38368, mosaic=0.77082, seed=42, val=True, patience=30, batch=2, device='0,1')| Class | Images | Class instances | Box precision | Box recall | Box mAP50 | Box mAP50-95 |
|---|---|---|---|---|---|---|
| Intersection | 25 | 10411 | 0.996 | 0.997 | 0.994 | 0.653 |
huoneistokortit_13082024.pt is downloaded to a folder \models\ huoneistokortit_13082024.pt
and the input image path is \data\image.jpg, inference can be perfomed using the following code:1from ultralytics import YOLO
2
3# Initialize model
4model = YOLO('\models\ huoneistokortit_13082024.pt')
5prediction_results = model.predict(source='\data\image.jpg', save=True)