No library generated after using using npu convert tools

I have a trained yolov3 (darknet) model that I am trying to convert by leveraging the npu SDK using both the python convert script and the c demo tool. In the past, I have been able to convert resnet18 model by converting a pretrained resnet18 PyTorch model to onnx and then converting the resulting onnx model to network_binary (.nb) files using the convert script as suggested in other posts on the khadas forum, followed by its successful deployment on khadas. Now, to convert the yolov3 model I follow two paths:

  1. In the first method I use the convert script with --platform darknet, essentially converting the darknet yolov3 model by using the command:
./convert --model-name yolov3 --platform darknet --model dota-yolov3-416.cfg --weights dota-yolov3-416_final.weights --inputs 000_net  --input-size-list '3,1024,1024' --mean-values '0,0,0,256' --quantized-dtype asymmetric_affine --kboard VIM3 --print-level 1 

The verbose output of the script can be found in this text file.
All the steps of the script are executed successfully except the library generation part indicated by the script ending with the following message (please refer to the entire verbose output in the link above):

Start export model ...
Done.Export model success !!!

Start generate library...

The expected result of this process is a nb file in the ‘outputs/model_name’ directory, however, I instead get a text file titled ‘pathfile’ in the outputs directory with the path ‘/tmp/MEIvdUVs’ which doesn’t exist.

  1. In the second method, I go the following route: yolov3 → onnx → .nb file. I convert the darknet yolov3 model using this python script. The resulting onnx model is then converted using the following command:
./convert --model-name yolov3 --platform onnx --model yolov3-1024,1024.onnx --inputs 000_net --input-size-list '3,1024,1024' --mean-values '103.94,116.78,123.68,58.82' --quantized-dtype asymmetric_affine --kboard VIM3 --print-level 1

The verbose output of the script can be found in this text file.
I was expecting this method to work out since this route had worked in the past for resnet18 model conversion as I mentioned before. However, I get the same issue as in method 1, i.e. no files are generated in the ‘output/model_name’ directory and I instead get a pathfile in the outputs directory.

Below are links to the yolov3 config file, network weights and the python script I am using to convert yolov3 to onnx.
converted onnx model
Following is a list of relevant package versions I am using:


Can I get some insight why the model conversion script is not working as expected?

@Prateek_Arora I suggest you try my command with darknet office model

$ ./convert \
--model-name yolov3 \
--platform darknet \
--model yolov3.cfg \
--weights yolov3.weights \
--mean-values '0,0,0,256' \
--quantized-dtype asymmetric_affine \
--kboard VIM3 --print-level 1

I had tried your command on my model but it yielded the same results. Unfortunately, I can’t use the official darknet model to convert since my yolov3 is trained on a different dataset that is relevant to my use case and accepts an image size of 1024x1024x3.
Is there any other tool that I can use to convert my model?
can I have access to source code of the conversion script?
If not, what are my options then?

@Prateek_Arora You provide me your cfg file and weights file, I will test it.

@Frank you can find the link to cfg file and weights in my
first post

cfg file: dota-yolov3-416.cfg - Google Drive
weights: dota-yolov3-416_final.weights - Google Drive
Here’s the link for your convenience. I appreciate you testing it out for me.

@Prateek_Arora I will find time to test as soon as possible

Hi @Frank, just checking in, if you got the chance to run the test.

@Prateek_Arora In my work plan for this week, the test will be tomorrow or the day after, and there are other things that are currently being dealt with

1 Like


$ ./convert \
--model-name yolov3 \
--platform darknet \
--model ~/yan/tmp/77777/dota-yolov3-416.cfg \
--weights ~/yan/tmp/77777/dota-yolov3-416_final.weights \
--mean-values '0,0,0,256' \
--quantized-dtype asymmetric_affine \
--kboard VIM3 --print-level 1

can be generated normally

 Done.Quantize success !!!

Start export model ...
Done.Export model success !!!

Start generate library...

Done.Generate library success !!!

All Done.

@Frank I am still getting the same results as I mentioned previously. I am using the convert tool (GitHub - khadas/aml_npu_sdk) mentioned in Instructions for KSNN conversion tool | Khadas Documentation
Are you using the same tools? or is your version different?

@Prateek_Arora Are you converting exactly according to my parameters? Or add your own extra parameters?

Yes, I am converting exactly according to your parameters

@Prateek_Arora Can you give me the command you use with my parameters and the printout? I’ve double-checked here, no problem

@Frank Here’s the command I use

./convert \
--model-name yolov3  \
--platform darknet  \
--model dota-yolov3-416.cfg \
--weights dota-yolov3-416_final.weights \
--mean-values '0,0,0,256' \
--quantized-dtype asymmetric_affine \
--kboard VIM3 --print-level 1

and here’s the link to the printout text file: printout.txt - Google Drive

I also took the liberty to record my screen so I can share exactly what’s going on. Here’s the link: Kazam_screencast_00002.mp4 - Google Drive

@Frank Is it possible for you to share the converted model files so that I can run it on khadas and check out the network’s performance?

@Prateek_Arora Have you installed the dependent python packages in the SDK repository instructions? I tried again here, it’s normal

I believe that I had to change the version of some packages due to compatibility issues with my existing framework. I will install the packages as listed in the SDK repo and try again.

@Prateek_Arora OK. I’ll consider making a docker image, if you still can’t figure it out

@Frank By satisfying the package version requirement as listed in requirement.txt, I was successfully able to convert the model.
Since I was able to convert the Resnet-18 PyTorch model using the existing version of packages on my system, I assumed it would work for the yolov3 conversion as well.

Although the requirement.txt list the compatible packages, for the purpose of documentation, below is the list of the package version that worked:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             4.5                       1_gnu  
absl-py                   1.0.0                    pypi_0    pypi
asgiref                   3.5.0                    pypi_0    pypi
astor                     0.8.0                    pypi_0    pypi
ca-certificates           2022.3.18            h06a4308_0  
cachetools                4.2.4                    pypi_0    pypi
certifi                   2021.10.8        py37h06a4308_2  
charset-normalizer        2.0.12                   pypi_0    pypi
cycler                    0.11.0                   pypi_0    pypi
decorator                 5.1.1                    pypi_0    pypi
dill                              pypi_0    pypi
django                    3.2.12                   pypi_0    pypi
flatbuffers               1.10                     pypi_0    pypi
gast                      0.2.2                    pypi_0    pypi
google-auth               1.35.0                   pypi_0    pypi
google-auth-oauthlib      0.4.6                    pypi_0    pypi
google-pasta              0.2.0                    pypi_0    pypi
grpcio                    1.44.0                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
idna                      3.3                      pypi_0    pypi
image                     1.5.5                    pypi_0    pypi
importlib-metadata        4.11.3                   pypi_0    pypi
keras-applications        1.0.8                    pypi_0    pypi
keras-preprocessing       1.1.2                    pypi_0    pypi
ld_impl_linux-64          2.35.1               h7274673_9  
libffi                    3.3                  he6710b0_2  
libgcc-ng                 9.3.0               h5101ec6_17  
libgomp                   9.3.0               h5101ec6_17  
libstdcxx-ng              9.3.0               hd4cf53a_17  
lmdb                      0.93                     pypi_0    pypi
markdown                  3.3.6                    pypi_0    pypi
matplotlib                2.1.0                    pypi_0    pypi
ncurses                   6.3                  h7f8727e_2  
networkx                  1.11                     pypi_0    pypi
numpy                     1.18.0                   pypi_0    pypi
oauthlib                  3.2.0                    pypi_0    pypi
onnx                      1.6.0                    pypi_0    pypi
openssl                   1.1.1n               h7f8727e_0  
opt-einsum                3.3.0                    pypi_0    pypi
pillow                    5.3.0                    pypi_0    pypi
pip                       21.2.2           py37h06a4308_0  
ply                       3.11                     pypi_0    pypi
protobuf                  3.11.2                   pypi_0    pypi
pyasn1                    0.4.8                    pypi_0    pypi
pyasn1-modules            0.2.8                    pypi_0    pypi
pyparsing                 3.0.7                    pypi_0    pypi
python                    3.7.11               h12debd9_0  
python-dateutil           2.8.2                    pypi_0    pypi
pytz                      2022.1                   pypi_0    pypi
readline                  8.1.2                h7f8727e_1  
requests                  2.27.1                   pypi_0    pypi
requests-oauthlib         1.3.1                    pypi_0    pypi
rsa                       4.8                      pypi_0    pypi
ruamel-yaml               0.15.81                  pypi_0    pypi
scipy                     1.1.0                    pypi_0    pypi
setuptools                58.0.4           py37h06a4308_0  
six                       1.16.0                   pypi_0    pypi
sqlite                    3.38.0               hc218d9a_0  
sqlparse                  0.4.2                    pypi_0    pypi
tensorboard               2.0.2                    pypi_0    pypi
tensorflow                2.0.0                    pypi_0    pypi
tensorflow-estimator      2.0.1                    pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
tk                        8.6.11               h1ccaba5_0  
torch                     1.2.0                    pypi_0    pypi
typing-extensions         4.1.1                    pypi_0    pypi
urllib3                   1.26.9                   pypi_0    pypi
werkzeug                  2.0.3                    pypi_0    pypi
wheel                     0.37.1             pyhd3eb1b0_0  
wrapt                     1.14.0                   pypi_0    pypi
xz                        5.2.5                h7b6447c_0  
zipp                      3.7.0                    pypi_0    pypi
zlib                      1.2.11               h7f8727e_4  

1 Like