Hm
So how then you converted pt weights in pb and os for Khadas in your ksnn example? Also I have troubles while converting pt → onnx → pb + os. Can you please provide a script where you converting pt → onnx (resnet example) and h5 → onnx
For pt to onnx, i use pytorch api, torch.onnx.export. I do not try to convert h5 to onnx. I search and find two ways. The api of tf2onnx, tf2onnx.convert.from_keras and the api of keras2onnx, keras2onnx.convert.from_keras. In addition, you can search on github to find other script.
I am sorry that the resnet model is not trained by myself. The details of resnet training, i do not know.
Could you provide your weights and structure pt model? Pytorch version does not have to 1.2.0.
First, you need to use torch.jit.save to save PyTorch model. The model saved by torch.save only is used on PyTorch but torch.jit.save can be used on other platform.
titan@titan:~/Desktop/aml_npu_sdk/acuity-toolkit/python$ ./convert --model-name resnet-example --platform pytorch --model /home/titan/Desktop/Work/ElCub/resnet_runs/train/exp2/last_1.pt --mean-values '103.94 116.78 123.68 0.01700102' --quantized-dtype asymmetric_affine --source-files /home/titan/Desktop/Work/ElCub/Calibration.txt --kboard VIM3 --print-level 0
--+ KSNN Convert tools v1.3 +--
Start import model ...
2024-04-04 17:26:58.574346: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/titan/Desktop/aml_npu_sdk/acuity-toolkit/bin/acuitylib:/tmp/_MEIH3DLo2
2024-04-04 17:26:58.574365: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
I Namespace(config=None, import='pytorch', input_size_list=None, inputs=None, model='/home/titan/Desktop/Work/ElCub/resnet_runs/train/exp2/last_1.pt', output_data='Model.data', output_model='Model.json', outputs=None, size_with_batch=None, which='import')
I Start importing pytorch...
[6794] Failed to execute script pegasus
Traceback (most recent call last):
File "pegasus.py", line 131, in <module>
File "pegasus.py", line 112, in main
File "acuitylib/app/importer/commands.py", line 294, in execute
It’s my bad, I’m using Pytorch 1.9, I know that it should be 1.5, but I’ve thought that mistake massage should be different for different Pytorch version