记录首次使用yolov8-obb
1.数据格式
之前使用的数据格式是yolov5_obb的数据格式,然后需要转数据格式:
目前的数据只支持四个坐标点标注的数据,参考:If a corner of the rotate rectangle is out of the image range, How to annotate the image? · Issue #7581 · ultralytics/ultralytics · GitHub
. YOLOv8 does not accept more than four points for a single object's annotation
数据格式转换为:
label_index x0 y0 x1 y1 x2 y2 x3 y3
数据不完整怎样进行数据标注:
If a corner of the rotate rectangle is out of the image range, How to annotate the image? · Issue #7581 · ultralytics/ultralytics · GitHub
2.训练环境的配置遇到的问题
1)
subprocess.CalledProcessError: Command '['/opt/conda/bin/python', '-m', 'torch.distributed.launch', '--nproc_per_node', '2', '--master_port', '44569', '/root/.config/Ultralytics/DDP/_temp_dutx5q5j140559331981920.py']' returned non-zero exit status 1.
解决办法:
终端输入:
export MKL_THREADING_LAYER=GNU
2)
ModuleNotFoundError: No module named 'ultralytics'
解决办法,安装依赖库:
pip install ultralytics
3)
ile "/opt/conda/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
解决办法:
apt-get install
apt-get install libglib2.0-dev
3.训练代码:
from ultralytics import YOLO
# Load a model
model = YOLO('yolov8n-obb.yaml') # build a new model from YAML
model = YOLO('./yolov8n-obb.pt')
# results = model.train(data='carddet.yaml', epochs=100, imgsz=640)
results = model.train(data='carddet.yaml', epochs=400, imgsz=640)