yolov8在钢轨故障识别的应用
##训练
from ultralytics import YOLO
if __name__ =="__main__":
model = YOLO("yolov8n.pt")
model.train(
data="/gap.yaml",
epochs=100,
imgsz=640,
device="0"##设备可使用cpu,值改为"cpu"
)
from ultralytics import YOLO
##预测
from ultralytics import YOLO
# Load a model
model = YOLO("/best.pt") # pretrained YOLOv8n model
# Run batched inference on a list of images
results = model(["/aug_prefix_0_1352.jpg"]) # return a list of Results objects
# Process results list
for result in results:
boxes = result.boxes # Boxes object for bounding box outputs
masks = result.masks # Masks object for segmentation masks outputs
keypoints = result.keypoints # Keypoints object for pose outputs
probs = result.probs # Probs object for classification outputs
obb = result.obb # Oriented boxes object for OBB outputs
result.show() # display to screen
result.save(filename="C:/Users/yusialone/Desktop/3d/its_rail/jieguo/result.jpg") # save to disk