How can i convert the trained model (yolov4-obj_best) into Pytorch (i.e.) from Darknet to Pytorch?

274 Views Asked by At
C:\Users\FHW>python demo_darknet2onnx.py yolov4-obj obj yolov4-obj_best train 64
Traceback (most recent call last):
  File "C:\Users\FHW\demo_darknet2onnx.py", line 5, in <module>
    "execution_count": null,
NameError: name 'null' is not defined

Currently I am using CUDA 11.2, CuDNN 11.2(v8.1.0.77), OpenCV 4.5.2, Cmake 3.19.6 and Python (3.10.9) from Anaconda environment. I am currently working on a Custom data object detection project using Yolov4 Darknet. After successfully completing the training of the model, I want to convert the trained model (yolov4-obj_best) into Pytorch (i.e.) from Darknet to Pytorch. so that I can convert the Pytorch model to the onnx model to do the inferencing with TensorRT.

I tried this repository https://github.com/Tianxiaomo/pytorch-YOLOv4 using the command:

pip install onnxruntime
python demo_darknet2onnx.py <cfgFile> <namesFile> <weightFile> <imageFile> <batchSize>

Executed command:
pip install onnxruntime
python demo_darknet2onnx.py yolov4-obj obj yolov4-obj_best train 64

yolov4-obj      = <cfgFile> denotes the cfg file where the custom configuration changes are made
obj             = <namesFile> denotes the name of two classes (i.e) weed and carrot
yolov4-obj_best = <weightFile> weights obtained after the training
train           = <imageFile> Here the image is in .txt form which contains the path of the images
64              = <batchSize>

After executing this command:

python demo_darknet2onnx.py yolov4-obj obj yolov4-obj_best train 64

in the Command prompt I am facing the following error which I have attached to the image above. I have also changed the execution count: from null to none.

How can I solve this error?

Can someone provide me with a solution?

Or can anyone give me another method to change my Darknet weights to ONNX or Pytorch?

0

There are 0 best solutions below