ultralytics / ultralytics

Ultralytics YOLO11 🚀
https://docs.ultralytics.com
GNU Affero General Public License v3.0
32.95k stars 6.35k forks source link

YOLOv8-Pose #13979

Open WYL-Projects opened 5 months ago

WYL-Projects commented 5 months ago

Search before asking

Question

Dear author, I have a small question, can YOLOv8-Pose be used for both license plate keypoints and face keypoints detection at the same time, say four keypoints for license plate and five keypoints for face.

Additional

No response

github-actions[bot] commented 5 months ago

👋 Hello @WYL-Projects, 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 5 months ago

@WYL-Projects hello,

Thank you for your question and for checking the existing issues and discussions before posting! 😊

Yes, YOLOv8-Pose can indeed be adapted to detect keypoints for multiple object types, such as license plates and faces, simultaneously. To achieve this, you need to ensure that your dataset is annotated correctly and that the model is configured to handle multiple keypoint sets.

Here's a high-level overview of how you can set this up:

  1. Dataset Preparation:

    • Annotate your dataset with the required keypoints for each object type. For example, annotate four keypoints for license plates and five keypoints for faces.
    • Ensure that your annotations follow the Ultralytics YOLO format for pose estimation. Each annotation should include the class index, bounding box coordinates, and keypoint coordinates.
  2. Dataset YAML Configuration:

    • Create a YAML file to define your dataset configuration. This file should specify the paths to your training and validation images, the number of keypoints, and the class names.
    • Here’s an example configuration for your case:

      path: ../datasets/custom-pose  # dataset root dir
      train: images/train  # train images (relative to 'path')
      val: images/val  # val images (relative to 'path')
      test:  # test images (optional)
      
      # Keypoints
      kpt_shape: [5, 3]  # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)
      flip_idx: []  # if applicable
      
      # Classes dictionary
      names:
      0: license_plate
      1: face
  3. Training the Model:

    • Use the following code to train your model with the custom dataset:

      from ultralytics import YOLO
      
      # Load a pretrained YOLOv8-Pose model
      model = YOLO("yolov8n-pose.pt")
      
      # Train the model on your custom dataset
      results = model.train(data="path/to/your/custom-pose.yaml", epochs=100, imgsz=640)

By following these steps, you can train a YOLOv8-Pose model to detect keypoints for both license plates and faces simultaneously. If you encounter any issues or need further assistance, please provide a reproducible example of your setup, as it will help us diagnose and address your issue more effectively. You can find more information on creating a minimum reproducible example here.

Feel free to reach out if you have any more questions. Happy training!

sc-huipu-pc commented 4 months ago

@glenn-jocher hello I have a question. If there are multiple categories and the keypoints for each category are different, there should be a problem with the "kpt_shape: [5,3]" written in your YAML above. Not all categories have a keypoint of 5,Is it written directly based on the highest number of keypoints? Do data with different keypoints like this need special processing in training labels,Looking forward to your answer

glenn-jocher commented 3 months ago

Hello @sc-huipu-pc,

You're correct that the kpt_shape parameter should reflect the highest number of keypoints among all categories. If different categories have varying numbers of keypoints, you should set kpt_shape to the maximum number of keypoints. For categories with fewer keypoints, you can pad the remaining keypoints with zeros or a specific value to maintain consistency in the label format. This ensures that the model can handle varying keypoint counts during training.

If you encounter any issues or need further assistance, please let us know.