Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ultralytics import YOLO
|
| 2 |
+
|
| 3 |
+
# Load a model
|
| 4 |
+
model = YOLO("yolov8n.pt")
|
| 5 |
+
|
| 6 |
+
# Train the model
|
| 7 |
+
train_results = model.train(
|
| 8 |
+
data="coco8.yaml", # path to dataset YAML
|
| 9 |
+
epochs=100, # number of training epochs
|
| 10 |
+
imgsz=640, # training image size
|
| 11 |
+
device="cpu", # device to run on, i.e. device=0 or device=0,1,2,3 or device=cpu
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
# Evaluate model performance on the validation set
|
| 15 |
+
metrics = model.val()
|
| 16 |
+
|
| 17 |
+
# Perform object detection on an image
|
| 18 |
+
results = model("path/to/image.jpg")
|
| 19 |
+
results[0].show()
|
| 20 |
+
|
| 21 |
+
# Export the model to ONNX format
|
| 22 |
+
path = model.export(format="onnx") # return path to exported model
|