点击下方卡片,关注“机器视觉与AI深度学习”
视觉/图像重磅干货,第一时间送达!
如何使用模型?
您可以参考https://docs.ultralytics.com/models/yolo11/#usage-examples上的文档来了解如何使用该模型。
!pip install ultralytics
from IPython import display
display.clear_output()
import ultralytics
ultralytics.checks()
from ultralytics import YOLO
from IPython.display import display, Image
! wget https://github.com/ultralytics/assets/releases/download/v 8.3.0 / yolo11x-seg.pt
import roboflow
roboflow.login()
rf = roboflow.Roboflow()
project = rf.workspace("model-examples").project("car-parts-instance-segmentation")
dataset = project.version(1).download("yolov11")
import yaml
with open(f"{dataset.location}/data.yaml", 'r') as f:
dataset_yaml = yaml.safe_load(f)
dataset_yaml["train"] = "../train/images"
dataset_yaml["val"] = "../valid/images"
dataset_yaml["test"] = "../test/images"
with open(f"{dataset.location}/data.yaml", 'w') as f:
yaml.dump(dataset_yaml, f)
%cd {HOME}
!yolo task=segment mode=train model="/content/yolo11x-seg.pt" data="/content/car-parts-instance-segmentation-1/data.yaml" epochs=10 imgsz=640
!ls {HOME}/runs/segment/train/
%cd {HOME}
Image(filename=f'{HOME}/runs/segment/train/confusion_matrix.png', width=600)
%cd {HOME}
Image(filename=f'{HOME}/runs/segment/train/results.png', width=600)
%cd {HOME}
Image(filename=f'{HOME}/runs/segment/train/val_batch0_pred.jpg', width=600)
%cd {HOME}
!yolo task=segment mode=val model={HOME}/runs/segment/train/weights/best.pt data={dataset.location}/data.yaml
%cd {HOME}
!yolo task=segment mode=predict model={HOME}/runs/segment/train/weights/best.pt conf=0.25 source={dataset.location}/test/images save=true
import glob
from IPython.display import Image, display
for image_path in glob.glob(f'{HOME}/runs/segment/predict2/*.jpg')[:3]:
display(Image(filename=image_path, height=600))
print("\n")
https://github.com/tententgc/notebook-colab/blob/main/yolo11x_segmentation.ipynb
https://github.com/tententgc/notebook-colab/blob/main/train_yolo11_object_detection_on_custom_dataset.ipynb
—THE END—
觉得有用,麻烦给个赞和在看