Skip to content

You can use this repository when you want to convert pytorch model to tensorflowLite model. To convert pytorch to TFLite, you also need to convert pytorch to onnx, and tensorflow. This repository has all that codes.

License

Notifications You must be signed in to change notification settings

Seungeun-Han/torch2otherModels-ONNX-Tensorflow-TensorflowLite

Repository files navigation

torch2otherModels(ONNX, Tensorflow, TensorflowLite)

This repository can be used to convert PyTorch to other types of model such as ONNX, Tensorflow and TensorflowLite.

If you want to convert pytorch to TFLite, to utilize the pretrained Deep Learning model in Android, you need to follow this step:

  1. Pytorch -> ONNX
  2. ONNX -> Tensorflow
  3. Tensorflow -> TensorflowLite

To illustrate how to use this code, consider converting ResNet18 (PyTorch Model) as an example.


How to use?

1. Pytorch -> ONNX

Run pytorch2onnx.py.

If converting has no problem, you can see "The model is valid!".


To customize

If you want to convert your model, you have to import your model and set the appropriate shape of input.


2. ONNX -> Tensorflow

Run onnx2tf.py.


To customize

Modify the file path or name(Name_of_ONNX, Name_of_TF)


3. Tensorflow -> TensorflowLite

Run tf2TFLite.py.


To customize

Modify the file path or name(TF_PATH, TFLite_name)

About

You can use this repository when you want to convert pytorch model to tensorflowLite model. To convert pytorch to TFLite, you also need to convert pytorch to onnx, and tensorflow. This repository has all that codes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages