https://github.com/google-ai-edge/ai-edge-torch
reference this paper. from https://github.com/google-ai-edge/ai-edge-torch
you need create a new conda envirenment for this project ,point is python >=3.9
i used 3.9 for python.
the deteils are as follows:
python 3.9
torch 2.4
protobuf 3.20.3
tensorflow 2.17.0
sympy 1.8
opencv-python 4.10.0.82
numpy 1.26.4
keras 3.5.0
ai-edge-torch 0.1.1
torch-xla 2.4.0
and so on..
remember set the :
export LD_LIBRARY_PATH=<path to Python installation>/lib:$LD_LIBRARY_PATH
<path to Python installation> means the conda's path
ex:/home/yunxi/anaconda3/envs/torch_tf
and add this code for your project:
os.environ["PJRT_DEVICE"]="CPU"
device = "cpu"
for inference add this :
edge_model = ai_edge_torch.convert(model.eval(), (inputs,))
edge_model.export("resnet18.tflite")
print("-------------------tflite save successful !!11!@@@@!!!--------------")