yolo训练部署相关代码
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from ultralytics import YOLO
|
||||
import os
|
||||
|
||||
# 设置工作目录为你的项目路径
|
||||
os.chdir("/home/bbit/mine/yolo/")
|
||||
|
||||
# Load a pretrained YOLO11n model
|
||||
model = YOLO("models/yolo11x.pt")
|
||||
|
||||
# Train the model on the COCO8 dataset for 100 epochs
|
||||
train_results = model.train(
|
||||
data="SilkwormCocoonDataset/data.yaml",
|
||||
epochs=100,
|
||||
imgsz=768,
|
||||
batch=8,
|
||||
device="cuda:0",
|
||||
amp=True,
|
||||
half=True,
|
||||
optimizer="auto",
|
||||
warmup_epochs=3,
|
||||
mosaic=1.0,
|
||||
mixup=0.1
|
||||
)
|
||||
|
||||
|
||||
# Evaluate the model's performance on the validation set
|
||||
metrics = model.val()
|
||||
|
||||
# # Perform object detection on an image
|
||||
# results = model("path/to/image.jpg") # Predict on an image
|
||||
# results[0].show() # Display results
|
||||
|
||||
# Export the model to ONNX format for deployment
|
||||
path = model.export(format="models/yolo11x_silkworm_cocoon") # Returns the path to the exported model
|
||||
Reference in New Issue
Block a user