"official/projects/yolo/modeling/backbones/darknet.py" did not exist on "3cb8437460fde14842c3950d29a695471c0745fe"
train_infer_coco.py 807 Bytes
Newer Older
chenzk's avatar
v1.0  
chenzk committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from ultralytics import YOLO


# 1.train
# Load a model
model = YOLO("yolo11s.pt")

# Train the model
train_results = model.train(
    data="coco8.yaml",  # path to dataset YAML, i.e. coco2017: coco.yaml
    epochs=500,  # number of training epochs
    batch=128, # batchsize, i.e. yolo11s: 128
    imgsz=640,  # training image size
    device="0,1,2,3",  # device to run on, i.e. device=0 or device=0,1,2,3 or device=cpu
)

# Evaluate model performance on the validation set
metrics = model.val()


'''
# 2.infer
# model = YOLO("runs/detect/train/weights/last.pt") # Load custom train model
# Perform object detection on an image
results = model("bus.jpg")
results[0].show()
'''

'''
# 3.export onnx
# Export the model to ONNX format
path = model.export(format="onnx")  # return path to exported model
'''