ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.16k stars 3.44k forks source link

How can I remove some of the objects from COCO dataset #1016

Closed daler-rahimov closed 4 years ago

daler-rahimov commented 4 years ago

I have fallowed Train Custom Data to train my custom model. But there are some classes/objects in COCO dataset that want to include as well. Is there fast way to extract only those classes from the dataset. I'm thinking to write a script to do so but it feels like there should my much faster way to accomplish this.

github-actions[bot] commented 4 years ago

Hello @daler-rahimov, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Google Colab Notebook, Docker Image, and GCP Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

glenn-jocher commented 4 years ago

@daler-rahimov I don't quite understand what you are asking. You want to train a subset of classes on all of the coco images? Or you want to add classes to the existing coco dataset?

daler-rahimov commented 4 years ago

@daler-rahimov I don't quite understand what you are asking. You want to train a subset of classes on all of the coco images? Or you want to add classes to the existing coco dataset?

Just subset of classes. Lets say I want to train only for cars, motorcycles and airplanes nothing else from COCO

glenn-jocher commented 4 years ago

@daler-rahimov then you can either modify the labels, or you can modify the dataloader to filter by class. The dataloader is here:

https://github.com/ultralytics/yolov3/blob/master/utils/datasets.py#L258

The last option is to train on all 80 classes, or just used the pretrained weights, and then run detection only for certain classes:

python3 detect.py --classes 0,3,5

zidane

daler-rahimov commented 4 years ago

@daler-rahimov then you can either modify the labels, or you can modify the dataloader to filter by class. The dataloader is here:

https://github.com/ultralytics/yolov3/blob/master/utils/datasets.py#L258

The last option is to train on all 80 classes, or just used the pretrained weights, and then run detection only for certain classes:

python3 detect.py --classes 0,3,5

zidane

Thank a lot for the help. This definitely will make my life much easier

joel5638 commented 4 years ago

@glenn-jocher Hi Glenn. I want to train my model only on 5 classes with coco dataset. But it's hard to find images and labels of few classes to train in the huge coco dataset. Is there are a way to only train a model on few classes?

glenn-jocher commented 4 years ago

@joel5638 as I mentioned earlier in the issue, you can train with updated your labels, or you can train on the full dataset and then display detection on only certain classes.

Alistar989 commented 2 years ago

Untitled

Hey, I tried applying the "!python3 detect.py --classes 0,3,5" in Google Colab in the Inference section but it's giving me an error. Anyway to solve this?

glenn-jocher commented 2 years ago

@Alistar989 argparser list arguments are space-separated as the help shows: https://github.com/ultralytics/yolov3/blob/0f80f2f9054dd06d34c51e73ea1bc5ba808fed18/detect.py#L218

Alistar989 commented 2 years ago

@Alistar989 argparser list arguments are space-separated as the help shows:

https://github.com/ultralytics/yolov3/blob/0f80f2f9054dd06d34c51e73ea1bc5ba808fed18/detect.py#L218

THANK YOU!!! I was stuck on this include/exclude situation for what felt like an eternity.

glenn-jocher commented 7 months ago

@Alistar989 You're welcome! I'm glad I could help. If you have any more questions or run into issues, feel free to ask. Happy training! 🚀