Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom object detection by retaining the original classes of yolo #13025

Open
1 task done
b4u365 opened this issue May 18, 2024 · 5 comments
Open
1 task done

Custom object detection by retaining the original classes of yolo #13025

b4u365 opened this issue May 18, 2024 · 5 comments
Labels
question Further information is requested

Comments

@b4u365
Copy link

b4u365 commented May 18, 2024

Search before asking

Question

I have custom data set with Road signs, Traffic barrales which need to be trained and detected retaining the earlier classes of yolov5s.pt like (Cars, pedistrains, etc). once i train with custom data set , yolo could only detect the trained objects like Traffic barrels but was not detecting the cars and persons. can you help me in resolving this issue were i need to detect both road signs, traffic barrales along with Cars, pedistians which was there in yolov5 deafult weights .

Additional

No response

@b4u365 b4u365 added the question Further information is requested label May 18, 2024
@glenn-jocher
Copy link
Member

@b4u365 hello! It sounds like you want to expand your model's capabilities to detect both new and existing classes. To achieve this, you'll need to train on a dataset that includes all desired classes — both the default ones like cars and pedestrians, and your custom classes like road signs and traffic barrels.

Here’s a quick guide:

  1. Dataset Preparation: Combine your custom dataset with a dataset containing the default YOLO classes. Ensure each class is properly labeled.

  2. Training: When setting up your training configuration in YOLOv5, update the *.yaml file to include all classes (default and custom). This means adjusting the number of classes and providing the names of each class.

  3. Model Training: Use the command to start training, ensuring to specify the path to your combined dataset and updated *.yaml file.

This approach ensures that the model learns to detect both old and new classes together. Good luck with your training! 😊

@b4u365
Copy link
Author

b4u365 commented May 19, 2024 via email

@glenn-jocher
Copy link
Member

@b4u365 hi Bharath,

Glad to hear the previous advice was helpful! Regarding your question about freezing layers:

  • Option A (Freezing Layers): Freezing most of the layers and only training the last few can indeed help in transferring the learned features from the large dataset used in yolov5s.pt. This approach is faster and consumes less computational resources. However, it might limit the model's ability to adapt to the new classes in your custom dataset.

  • Option B (Training All Layers): This option allows the model to better adapt to the new data, potentially improving accuracy for your custom classes at the expense of more extensive computation and training time.

Given your goal of retaining the original quality of yolov5s.pt while adding new capabilities, I'd recommend starting with Option A to leverage the pre-trained features and then, if necessary, fine-tuning with Option B based on the performance and results you observe.

Best of luck with your training! 😊

@b4u365
Copy link
Author

b4u365 commented May 19, 2024 via email

@glenn-jocher
Copy link
Member

Hi Bharath,

It sounds like freezing the layers might be too restrictive for adapting to your new classes while maintaining performance on the original ones. I recommend gradually unfreezing some of the earlier layers to allow more flexibility in learning features relevant to both new and existing classes. You can start by unfreezing earlier layers incrementally and observing the impact on performance.

Here's a modified command to unfreeze some earlier layers:

python train.py --freeze 10 11 12 13 14 15 16 18 19 21 22

This approach strikes a balance between leveraging pre-trained features and adapting to new data. Let's see how this adjustment works out! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants