ultralytics / ultralytics

Ultralytics YOLO11 πŸš€
https://docs.ultralytics.com
GNU Affero General Public License v3.0
32.16k stars 6.17k forks source link

evaluation on custom dataset (YoloV8 OBB) #9123

Closed Petros626 closed 7 months ago

Petros626 commented 7 months ago

Search before asking

Question

Is it possible to evaluate model with the oriented bounding box on a custom dataset or only on DOTA? I read the documenation here: https://docs.ultralytics.com/de/tasks/obb/#val and didn't found a part about custom evaluation.

Thanks in advance

Additional

No response

github-actions[bot] commented 7 months ago

πŸ‘‹ Hello @Petros626, thank you for your interest in Ultralytics YOLOv8 πŸš€! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a πŸ› Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

glenn-jocher commented 7 months ago

@Petros626 hello! 😊 Yes, you can absolutely evaluate models with oriented bounding boxes (OBBs) on custom datasets, not just DOTA. For this, you'll first need to prepare your custom dataset in a similar format as supported by YOLOv8 for OBB tasks.

Make sure your dataset annotations are structured properly (refer to the DOTA or similar dataset formatting guidelines). After that, you can simply specify your custom dataset in the YAML file and use it for validation just like you would with any YOLO model.

Here's a quick example on how you might specify this in your custom dataset YAML and execute the validation process:

# custom_dataset.yaml
path: ../datasets/my_custom_dataset  # dataset root dir
train: images/train  # train images relative path
val: images/val  # val images relative path
test:  # optional test images relative path

# Assuming 'classes.txt' lists all your classes
nc: 10  # number of classes
names: ['class1', 'class2', ..., 'class10']  # class names

And then run validation with:

yolo val data=custom_dataset.yaml model=yolov8n-obb.pt

Ensure your classes and paths are correctly defined according to your actual dataset structure. Happy evaluating! If you have more specific questions or run into issues, feel free to ask.

Petros626 commented 7 months ago

@glenn-jocher thank you for the exact and fast answer!

glenn-jocher commented 7 months ago

@Petros626 You're welcome! 😊 If you have any more questions or need further assistance, don't hesitate to reach out. Happy detecting!

Petros626 commented 4 months ago

Hello Ultralytics team. I want to create a label dataset according to bounding box values and angles for Yolov8-obb training. How can I extract the labels?

You should open a separate issue or search for a similar than using a totally different question.

glenn-jocher commented 3 months ago

Hello @Petros626,

Thank you for your question! To create a label dataset for YOLOv8-OBB training, you'll need to format your annotations in the YOLO OBB format, which specifies bounding boxes by their four corner points with coordinates normalized between 0 and 1. Here's a quick guide:

  1. Annotation Format: Each line in your label file should follow this format:

    class_index, x1, y1, x2, y2, x3, y3, x4, y4

    For example:

    0 0.780811 0.743961 0.782371 0.74686 0.777691 0.752174 0.776131 0.749758
  2. Dataset Structure: Ensure your dataset directory is structured properly with images and corresponding label files.

  3. YAML Configuration: Create a YAML file to specify the paths and class names for your dataset. Here’s an example:

    path: ../datasets/my_custom_dataset
    train: images/train
    val: images/val
    nc: 10
    names: ['class1', 'class2', ..., 'class10']
  4. Conversion Script: If your current annotations are in a different format (e.g., DOTA), you can use the provided conversion script:

    from ultralytics.data.converter import convert_dota_to_yolo_obb
    convert_dota_to_yolo_obb("path/to/DOTA")
  5. Training: Once your dataset is ready, you can start training:

    yolo detect train data=custom_dataset.yaml model=yolov8n-obb.pt epochs=100 imgsz=640

For more detailed instructions, please refer to our documentation.

If you encounter any issues, please provide a reproducible example to help us assist you better: Minimum Reproducible Example.

Best of luck with your training! πŸš€