eriklindernoren / PyTorch-YOLOv3

Minimal PyTorch implementation of YOLOv3
GNU General Public License v3.0
7.31k stars 2.63k forks source link

how to set custom path for labels? please help me #819

Closed J-LINC closed 1 year ago

J-LINC commented 1 year ago

How can I modify the path of labels? For example, I want to divide the labels of the training set and the verification set into two subfolders, such as custom/tables ->custom/BDD100K/labels/train and custom/BDD100K/labels/val. It seems that the labels can only be placed in one folder

jaagut commented 1 year ago

You can do this, by changing the path in your <config-file>.data. See this example file. This file points to two .txt files, one for training and one for validation/verification.

In the example, the configuration points to this train.txt and this valid.txt. Currently, each of those only contains one entry. The purpose of these train.txt and valid.txt files is to point to the image files that comprise your train and verification datasets. Each image-path in a new line.

For further information, read here, especially here

I hope, this helped. If you have further questions, please don't hesitate to ask.

J-LINC commented 1 year ago

You can do this, by changing the path in your <config-file>.data. See this example file. This file points to two .txt files, one for training and one for validation/verification.

In the example, the configuration points to this train.txt and this valid.txt. Currently, each of those only contains one entry. The purpose of these train.txt and valid.txt files is to point to the image files that comprise your train and verification datasets. Each image-path in a new line.

For further information, read here, especially here

I hope, this helped. If you have further questions, please don't hesitate to ask.

First of all, thank you for your reply. I don't know if I made a mistake. EMmm, you mentioned the path for setting up the training set and verification set images, but I meant the path for the labels. In the original text, it was pointed out that the training set and verification set labels need to be placed in the labels folder, which means they are mixed together, but I want to separate the training and verification subfolders under the labels folder to store their respective label files

Flova commented 1 year ago

The train and validation datasets are completely independent. They are defined by the txt files that contain relative or absolute paths to the individual images (if you use relative ones make sure to start at the correct folder). You just need to make sure, that the images are in a folder called images and the labels are in a folder called labels. We look for each of the images paths in the respective txt also into the labels folder and search for a file with the same base name and the txt file extension. You should therefore be able to place all images and labels into the same folders or different ones as long as the naming follows the pattern I described.

Flova commented 1 year ago

In short this is valid:

bla/set1/labels/image1.txt bla/set2/labels/image2.txt

This is also valid:

bla/set1/labels/image1.txt bla/set1/labels/image2.txt

This is invalid:

bla/labels/set1/image1.txt bla/labels/set2/image2.txt

Note that you need to also adapt the set1.txt and set2.txt files accordingly and that they contain the image, not the label paths. The label paths are inferred automatically.

J-LINC commented 1 year ago

This is the answer I want. By the way, Thank you very much for your excellent code!!!!

Flova commented 1 year ago

No problem. Thank you very much, let me know it there are any other issues.