Comments (5)
TFLite model
Steps to create the TFLite model
-
Convert raw model to TF checkpoints
$ python3 save_model.py --weights ./data/yolov4-tiny.weights --output ./checkpoints/yolov4-tiny-416-tflite --input_size 416 --model yolov4 --tiny --framework tflite
-
Convert checkpoints to TFLite model
$ python3 convert_tflite.py --weights ./checkpoints/yolov4-tiny-416-tflite --output ./checkpoints /yolov4-tiny-416.tflite
-
Run a testing inference by using the TFLite model
$ python3 detect.py --weights ./checkpoints/yolov4-tiny-416.tflite --size 416 --model yolov4 --image ./data/kite.jpg --framework tflite
Benchmark
CPU: Intel i7-10710U (12-core)
Inference takes 0.11111974716186523 s
Environment
- tensorflow-yolov4-tflite: commit
dafb42f
- tensorflow-cpu: 2.2.0
from berrynet.
Darknet benchmark
- v4
- Standard: 26s
- Tiny: 2.1s
- v3
- Standard: 28s
- Tiny: 2.1s
from berrynet.
Failed to run the TFLite model on RPi 4:
pi@raspberrypi:~/codes/tensorflow-yolov4-tflite $ python3 detect.py --weights ./checkpoints/yolov4-tiny-416.tflite --size 416 --model yolov4 --image ./data/kite.jpg --framework tflite
Traceback (most recent call last):
File "detect.py", line 90, in <module>
app.run(main)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 300, in run
_run_main(main, args)
File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 251, in _run_main
sys.exit(main(argv))
File "detect.py", line 49, in main
interpreter = tf.lite.Interpreter(model_path=FLAGS.weights)
File "/usr/local/lib/python3.7/dist-packages/tensorflow/lite/python/interpreter.py", line 77, in __init__
model_path))
ValueError: Didn't find op for builtin opcode 'RESIZE_BILINEAR' version '3'
Registration failed.
TF Wheel is from PINTO0309
pi@raspberrypi:~/codes/tensorflow-yolov4-tflite $ python3 -m pip freeze | grep tensorflow
tensorflow==1.14.0
tensorflow-estimator==1.14.0
Solution
Upgrade TF from 1.14.0 to 2.2.0 can fix this issue.
from berrynet.
YOLOv4 Tiny (TFLite) inference time on RPi 4
pi@raspberrypi:~/codes/tensorflow-yolov4-tflite $ python3 detect.py --weights ./checkpoints/yolov4-tiny-416.tflite --size 416 --model yolov4 --image ./data/kite.jpg --framework tflite
[{'name': 'input_1', 'index': 0, 'shape': array([ 1, 416, 416, 3]), 'shape_signature': array([ 1, 416, 416, 3]), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]
[{'name': 'Identity', 'index': 224, 'shape': array([ 1, 2535, 4]), 'shape_signature': array([ 1, 2535, 4]), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}, {'name': 'Identity_1', 'index': 206, 'shape': array([ 1, 2535, 80]), 'shape_signature': array([ 1, 2535, 80]), 'dtype': <class 'numpy.float32'>, 'quantization': (0.0, 0), 'quantization_parameters': {'scales': array([], dtype=float32), 'zero_points': array([], dtype=int32), 'quantized_dimension': 0}, 'sparsity_parameters': {}}]
Inference takes 0.8501577377319336 s
from berrynet.
YOLOv4 Tiny TFLite model and label files: #49 (comment)
from berrynet.
Related Issues (20)
- Error in updating the pkg or installing HOT 1
- 3.9.0 depends on darknet which is not available in BerryNet repo HOT 1
- Missing dependencies in setup.py
- cpu_extension content has been merged into MKLDNN plugin since OpenVINO 2020.1
- Use opencv in distribution instead of berrynet-repo for bionic HOT 1
- Change dependency python3-opengl to freeglut3
- [FR] Every client and service can create its own logger
- [FR] Update OpenVINO 2021.2 (w/ Python 3.8 support) HOT 7
- [Bug Report] CI is currently broken
- Regarding tensorflow on manual installation HOT 1
- CNCF-Runtime discussion/presentation(?) HOT 2
- [Bug Report] pkg_resources.DistributionNotFound: The 'paho-mqtt' distribution was not found and is required by berrynet HOT 6
- [FR] Support Raspberry Pi OS 64-bit (beta version) HOT 1
- Can I run the darknet with multi-thread in the Raspberry? HOT 2
- [Bug Report] Debian berrynet package /usr//bin/bn_pipeline doesn't run
- [FR] Update TFLite 2.4.0 HOT 1
- [FR] Add YOLOv4 Training Tutorial
- [FR] Automate Debian repository uploading
- [Bug Report]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from berrynet.