PurdueDualityLab / TensorFlowModels

Model Reconstruction Team for TensorFlow 2.x Model Garden
25 stars 13 forks source link

Building the YOLO v4 from scratch using my annotations #38

Open kalikhademi opened 3 years ago

kalikhademi commented 3 years ago

Hi all,

Thanks for your great content on this repo! I am interested to use my annotations and pictures to train a YOLO model. I went through your repo and changed the annotations with mine. However, I am not sure about steps I need to take to generate yolo.weights, yolo.cfg, and .yaml files. I think it would great if you can put an example which shows all steps from scratch as it would solve the confusion for so many people.

Also, I tried to download the saved model and checkpoints from the table you have but the links did not work.

anivegesana commented 3 years ago

Hi @kalikhademi,

Sorry for the late reply. I have been out traveling for a little bit and haven't been up-to-date on my messages.

The .cfg and .weights files are the Darknet format for storing a model. These are the weights that were provided by the authors of the paper and can be downloaded here. Pretrained weights for the CSPDarknet model provided by the authors of the CSPNet paper can be found here. Our implementation can read this format, but it cannot convert the TensorFlow checkpoints back into a Darknet-compatible model.

The .yaml files in our repo are related to the TensorFlow Model Garden and allow you to configure the model. The hyperparameters are defined in the config classes. Better documentation is forthcoming, but we recommend copying one of the existing YAML files in the experiments folder and changing it to what best suits you.

Our implementation, however, still doesn't entirely reproduce the original paper yet. It still is 1% less accurate based on the mAP metric, so we haven't uploaded pretrained models yet. Regardless, it is still possible to train the model from scratch using a custom dataset with our implementation.

What format are your annotations in? If the format is in the TFDS format with the same features as their COCO dataset or in preprocessed TFRecords in the same format as the tensorflow/tpu repo, it can very likely be used in our implementation with very little modification. If not, it is probably easiest to create your own in the TFDS format. Here is an example of how it will end up looking like if you were converting the dataset from the YOLO paper's format into TFDS.

Hope this helps.

kalikhademi commented 3 years ago

Hi @anivegesana,

Thanks for the reply! I have the coco style annotations for my dataset. Do I need to change them to TFDS format to use with your code? Could you please give me a rough steps I need to take to run with my own dataset. I already trained a darknet model on my data so I have the weights and config files.