Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert into tflite #26

Open
Harsh-Vavaiya opened this issue Oct 2, 2020 · 2 comments
Open

Convert into tflite #26

Harsh-Vavaiya opened this issue Oct 2, 2020 · 2 comments

Comments

@Harsh-Vavaiya
Copy link

Hi, @foamliu I want to test this model into mobile can you help me how to convert it in tflite model ?

@Harsh-Vavaiya
Copy link
Author

`import tensorflow as tf
from utils import load_model

if name == 'main':
img_width, img_height = 224, 224
model = load_model()
tflite_converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = tflite_converter.convert()
open("models/model.96-0.89.tflite", "wb").write(tflite_model)`

Tried this, but its giving error:
loc(fused[callsite("functional_3/scale_conv1/mul"("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py":1457:0) at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py":1125:0 at callsite("D:\fiverr\mrh_21\Car-Recognition\custom_layers\scale_layer.py":65:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py":302:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py":985:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py":508:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py":385:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py":985:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\saving\saving_utils.py":134:0 at "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":600:0))))))))), callsite("functional_3/conv1/Conv2D"("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":1073:0) at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":1167:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\lite\python\lite.py":804:0 at callsite("D:/fiverr/mrh_21/Car-Recognition/tflite_coverter.py":19:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py":18:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":1438:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":1431:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":2122:0 at "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":2131:0)))))))), callsite("functional_3/bn_conv1/FusedBatchNormV3"("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":1073:0) at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":1167:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\lite\python\lite.py":804:0 at callsite("D:/fiverr/mrh_21/Car-Recognition/tflite_coverter.py":19:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py":18:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":1438:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":1431:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":2122:0 at "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":2131:0)))))))), callsite("functional_3/res2c_branch2b/Conv2D"("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":1073:0) at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":1167:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\lite\python\lite.py":804:0 at callsite("D:/fiverr/mrh_21/Car-Recognition/tflite_coverter.py":19:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev_pydev_imps_pydev_execfile.py":18:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":1438:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":1431:0 at callsite("C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":2122:0 at "C:\Program Files\JetBrains\PyCharm 2020.1\plugins\python\helpers\pydev\pydevd.py":2131:0)))))))), callsite("functional_3/scale_conv1/Reshape"("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\backend.py":2911:0) at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\dispatch.py":201:0 at callsite("D:\fiverr\mrh_21\Car-Recognition\custom_layers\scale_layer.py":65:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\autograph\impl\api.py":302:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py":985:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py":508:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\functional.py":385:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py":985:0 at callsite("C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\saving\saving_utils.py":134:0 at "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\eager\def_function.py":600:0)))))))))]): error: non-broadcastable operands: 'tensor<64x7x7x3xf32>' and 'tensor<1x1x1x64xf32>'

@Usman-Ghani123
Copy link

Have you downloaded the respective weight file?
bcoz the weight file link is given in readme section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants