omerferhatt / torch2tflite

PyTorch to TensorFlow Lite converter
MIT License
181 stars 43 forks source link

Fails to create .tflite #1

Closed rakshith-rm closed 3 years ago

rakshith-rm commented 3 years ago

ValueError: Could not open './converter/tf_lite_model.tflite'.

I've loaded my .pt file and a sample test image....but looks like the conversion is not working. Can you rectify this?

Thanks

omerferhatt commented 3 years ago

Could you send the error/output. This converter is not dynamic, you have to check errors in conversion steps.

rakshith-rm commented 3 years ago

Below is the following error that I got:

F:\torch2tflite>python converter.py --torch-model-path ./cpts/latest_net_G.pth --tf-lite-model-path ./converter/tf_lite_model.tflite --test-im-path ./converter/test_images/test.jpg --show-results --convert 2021-01-20 18:57:55.850158: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found 2021-01-20 18:57:55.855156: 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. Showing result!

Traceback (most recent call last): File "converter.py", line 58, in main() File "converter.py", line 31, in main torch_model, tf_lite_model = init_models(args.torch_model_path, args.tf_lite_model_path) File "converter.py", line 13, in init_models tf_lite_model = get_tf_lite_model(tf_lite_model_path) File "F:\torch2tflite\converter\torch_to_tflite.py", line 97, in get_tf_lite_model interpret = tf.lite.Interpreter(model_path) File "C:\Users\RAKSHITH R M\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\lite\python\interpreter.py", line 198, in init model_path, self._custom_op_registerers)) ValueError: Could not open './converter/tf_lite_model.tflite'.

I've put the .pth file under 'cpts' directory.

Thanks

mozeqiu commented 3 years ago

hello @omerferhatt when i convert my model to tflite ,i get some issues like this---> (torch2tflite) root@mysafetrain-nb:/home/pytorch/torch2tflite/torch2tflite# python3 converter.py --torch-model-path best.pt --tf-lite-model-path best.tflite --test-im-path 000008.jpg --show-results --convert Showing result!

Traceback (most recent call last): File "converter.py", line 58, in main() File "converter.py", line 31, in main torch_model, tf_lite_model = init_models(args.torch_model_path, args.tf_lite_model_path) File "converter.py", line 13, in init_models tf_lite_model = get_tf_lite_model(tf_lite_model_path) File "/home/pytorch/torch2tflite/torch2tflite/converter/torch_to_tflite.py", line 97, in get_tf_lite_model interpret = tf.lite.Interpreter(model_path) File "/root/.virtualenvs/torch2tflite/lib/python3.6/site-packages/tensorflow/lite/python/interpreter.py", line 204, in init model_path, self._custom_op_registerers)) ValueError: Could not open 'best.tflite'. but i just want to get tflite mdoel,can you help me?