How to load darknet YOLOv3 model from .cfg file and weights from .weights file, and save the model with the weights to a .h5 file?


I have downloaded the .weights and .cfg file for YOLOv3 from darknet (link: I want to create a model and assign the weights from these files, and I want to save the model with the assigned weights to a .h5 file so that I can load the .h5 model into Keras by using keras.models.load_model().

Please help.


You should check the instructions given in this repository. This is basically the keras implementation of YOLOv3 (Tensorflow backend).

  • Download YOLOv3 weights from YOLO website.
  • Convert the Darknet YOLO model to a Keras model.

    python yolov3.cfg yolov3.weights model_data/yolo.h5

As you have already downloaded the weights and configuration file, you can skip the first step. Download the script from repository and simply run the above command.

Note: Above command assumes that yolov3.cfg, yolov3.weights and model_data(folder) are present at the same path as

Answered By – Anubhav Singh

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published