Giter Club home page Giter Club logo

Comments (5)

bafu avatar bafu commented on August 19, 2024

TFLite model

yolov4-tiny-416.zip

Steps to create the TFLite model

  1. 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
    
  2. Convert checkpoints to TFLite model

    $ python3 convert_tflite.py --weights ./checkpoints/yolov4-tiny-416-tflite --output ./checkpoints    /yolov4-tiny-416.tflite
    
  3. 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

detect.py.patch.txt

CPU: Intel i7-10710U (12-core)

Inference takes 0.11111974716186523 s

Environment

  • tensorflow-yolov4-tflite: commit dafb42f
  • tensorflow-cpu: 2.2.0

from berrynet.

bafu avatar bafu commented on August 19, 2024

Darknet benchmark

CPU: Intel Pentium Gold G5400

  • v4
    • Standard: 26s
    • Tiny: 2.1s
  • v3
    • Standard: 28s
    • Tiny: 2.1s

from berrynet.

bafu avatar bafu commented on August 19, 2024

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.

bafu avatar bafu commented on August 19, 2024

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.

bafu avatar bafu commented on August 19, 2024

YOLOv4 Tiny TFLite model and label files: #49 (comment)

from berrynet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.