I want to train yolov5 by combining the coco dataset and the custom dataset created with roboflow. How do I merge datasets?
Asked
Active
Viewed 947 times
2 Answers
3
Create a data configuration file combined_datasets.yaml
that combines multiple datasets like this:
path: ../../yolov5_datasets # realative data root dir
train: # train images (relative to 'path')
- coco_dataset/train/images # use both coco
- custom_dataset/train/images # and you custom dataset for train
val: # val images
- coco_dataset/val/images # use both coco
- custom_dataset/val/images # and you custom dataset for eval
# Classes
nc: N # number of classes
names: [ 'name_0', 'name_1', '...', 'name_N-1' ] # class names
Specify it for training:
python train.py --data combined_datasets.yaml --cfg yolov5s.yaml --weights yolov5s.pt --device 2 --img 320

Mike B
- 2,136
- 2
- 12
- 31
-
wouldn't this mean that COCO dataset has to be downloaded locally? we are talking about more than 100,000 photos – ctrl_z Jul 19 '23 at 14:36
-
How do you otherwise intend to train the model if the data is not stored locally? – Mike B Jul 19 '23 at 16:18
-
can't it be accessed via COCO API? – ctrl_z Jul 20 '23 at 09:15
-
From the COCOAPI repo: "**After downloading** the images and annotations, run the Matlab, Python, or Lua demos for example usage.". You have to downward the data, there is now way around it. – Mike B Jul 20 '23 at 11:24
-
It is not that much data. COCO2017 train is comprised of 118.287 images, test 40.670 and validation 5.000. In total ~25GB of data. – Mike B Jul 20 '23 at 11:33
-
ok, thanks a lot! in any case training is faster with a dedicated GPU or Colab I'd say – ctrl_z Jul 20 '23 at 13:38
-
Yes, GPU is a must to train on COCO – Mike B Jul 20 '23 at 14:33
0
can I ask why you’re looking to combine the two?
Are you just wanting to do Transfer Learning to accelerate your model training and inference performance? If that’s the case, you can just use Train From Checkpoint, with Roboflow Train, and use the COCO checkpoint - https://docs.roboflow.com/train
Otherwise, is your goal to detect your custom classes alongside all of the classes in COCO?

Mohamed Traore
- 191
- 3
-
I want to train 1 or 2 custom datasets and people, bed classes from the coco dataset at once. Is Roboflow Train paid? Free is required. – NSA Sep 26 '22 at 01:57