peace195 / tensorflow-lite-yolov3 Goto Github PK
View Code? Open in Web Editor NEWYOLOv3: convert .weights to .tflite format for tensorflow lite. Convert .weights to .pb format for tensorflow serving
YOLOv3: convert .weights to .tflite format for tensorflow lite. Convert .weights to .pb format for tensorflow serving
I'm sorry if this sounds like a stupid question, but does tensorflow lite even support yolov3 models? I have migrated the model to .tflite format, but I haven't found a working example. All examples that I can find are all using yolov2. It would be very helpful is an example for iOS and/or Android can be provided. A link is also OK.
"TOCO failed. See console for info.\n%s\n%s\n" % (stdout, stderr))
tensorflow.lite.python.convert.ConverterError: TOCO failed. See console for info.
2019-11-25 09:28:17.070371: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 1012 operators, 1562 arrays (0 quantized)
2019-11-25 09:28:17.128413: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 1012 operators, 1562 arrays (0 quantized)
2019-11-25 09:28:18.329709: F tensorflow/lite/toco/graph_transformations/propagate_fixed_sizes.cc:722] Check failed: start_array.data_type == ArrayDataType::kInt32 Range op inputs must be int32.
Aborted (core dumped)
I can not convert this ...
I need helps to review the YOLOv3 tensorflow version: https://github.com/peace195/tensorflow-lite-yolo-v3/blob/master/yolo_v3.py
It is the cause of reducing performance when using .pb and .tflite compare with darknet .weights.
Hello, I tried to run tflite_example.py on multiple different images.
Some runs smoothly, other crashed with different error code. The images can be found here
scream.jpg
Traceback (most recent call last):
File "tflite_example.py", line 160, in <module>
draw_boxes(boxes, classes, scores, img, class_names, (height, width), True)
File "tflite_example.py", line 106, in draw_boxes
for box, score, cls in zip(boxes, scores, classes):
TypeError: zip argument #1 must support iteration
girl.png
Traceback (most recent call last):
File "tflite_example.py", line 153, in <module>
interpreter.set_tensor(input_details[0]['index'], np.expand_dims(img_resized, 0))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/interpreter.py", line 197, in set_tensor
self._interpreter.SetTensor(tensor_index, value)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/lite/python/interpreter_wrapper/tensorflow_wrap_interpreter_wrapper.py", line 136, in SetTensor
return _tensorflow_wrap_interpreter_wrapper.InterpreterWrapper_SetTensor(self, i, value)
ValueError: Cannot set tensor: Dimension mismatch. Got 4 but expected 3 for dimension 3 of input 103.
kite.jpg and person.jpg runs fine
tensorflow 2.0
slim = tf.contrib.slim
module 'tensorflow' has no attribute 'contrib'
https://www.tensorflow.org/guide/migrate
A note on Slim & contrib.layers
A large amount of older TensorFlow 1.x code uses the Slim library, which was packaged with TensorFlow 1.x as tf.contrib.layers. As a contrib module, this is no longer available in TensorFlow 2.0, even in tf.compat.v1. Converting code using Slim to TF 2.0 is more involved than converting repositories that use v1.layers. In fact, it may make sense to convert your Slim code to v1.layers first, then convert to Keras.
Remove arg_scopes, all args need to be explicit
If you use them, split normalizer_fn and activation_fn into their own layers
Separable conv layers map to one or more different Keras layers (depthwise, pointwise, and separable Keras layers)
Slim and v1.layers have different arg names & default values
Some args have different scales
If you use Slim pre-trained models, try out Keras's pre-traimed models from tf.keras.applications or TF Hub's TF2 SavedModels exported from the original Slim code.
Some tf.contrib layers might not have been moved to core TensorFlow but have instead been moved to the TF add-ons package.
This might be a version compatibility, but any help is appreciated as I can't find the resources to solve it,
After trying to run a simple app using the tflite converted model, I get this error:
Op builtin_code out of range: 97. Are you using old TFlite binary with newer model?
Thanks in advance.
I did not use docker. .I used the following command line on Pycharm Terminal based on Windows 10 platform.
"tflite_convert --saved_model_dir=saved_model/ --output_file yolo_v3.tflite --saved_model_signature_key='predict'"
However, it showed that
ModuleNotFoundError: No module named 'tensorflow.contrib.lite.python.tflite_convert'
Is the error because of my Tensorflow version? Mine is Tensorflow 1.13.1.
I would appreciate if you can help.
Thanks for your work!
When running the docker setup there seems to be a difference in the path and the actual repository name:
"tensorflow-lite-yolo-v3" should be changed to "tensorflow-lite-YOLOv3"
Please let me know if that makes sense.
I tried converting a model and uploading it to a phone through android studio...
Can't seem to get it to work. Looks like I don't have metadata? Always something with tensorflow :(
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.tensorflow.lite.examples.detection, PID: 1960
java.lang.IllegalStateException: This model does not contain associated files, and is not a Zip file.
at org.tensorflow.lite.support.metadata.MetadataExtractor.assertZipFile(MetadataExtractor.java:325)
at org.tensorflow.lite.support.metadata.MetadataExtractor.getAssociatedFile(MetadataExtractor.java:165)
at org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.create(TFLiteObjectDetectionAPIModel.java:116)
at org.tensorflow.lite.examples.detection.DetectorActivity.onPreviewSizeChosen(DetectorActivity.java:99)
at org.tensorflow.lite.examples.detection.CameraActivity$7.onPreviewSizeChosen(CameraActivity.java:446)
at org.tensorflow.lite.examples.detection.CameraConnectionFragment.setUpCameraOutputs(CameraConnectionFragment.java:357)
at org.tensorflow.lite.examples.detection.CameraConnectionFragment.openCamera(CameraConnectionFragment.java:362)
at org.tensorflow.lite.examples.detection.CameraConnectionFragment.access$300(CameraConnectionFragment.java:66)
at org.tensorflow.lite.examples.detection.CameraConnectionFragment$3.onSurfaceTextureAvailable(CameraConnectionFragment.java:171)
at android.view.TextureView.getTextureLayer(TextureView.java:400java.lang.IllegalStateException: This model does not contain associated files, and is not a Zip file)
at android.view.TextureView.draw(TextureView.java:349)
at android.view.View.updateDisplayListIfDirty(View.java:20876)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.updateDisplayListIfDirty(View.java:20867)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.updateDisplayListIfDirty(View.java:20867)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.draw(View.java:22002)
at android.view.View.updateDisplayListIfDirty(View.java:20876)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1246)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.draw(View.java:22002)
at android.view.View.updateDisplayListIfDirty(View.java:20876)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.updateDisplayListIfDirty(View.java:20867)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.updateDisplayListIfDirty(View.java:20867)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.updateDisplayListIfDirty(View.java:20867)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.updateDisplayListIfDirty(View.java:20867)
at android.view.View.draw(View.java:21731)
at android.view.ViewGroup.drawChild(ViewGroup.java:4432)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4193)
at android.view.View.draw(View.java:22002)
at com.android.internal.policy.DecorView.draw(DecorView.java:826)
at android.view.View.updateDisplayListIfDirty(View.java:20876)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:581)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:587)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:664)
E/AndroidRuntime: at android.view.ViewRootImpl.draw(ViewRootImpl.java:3817)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3545)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2829)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1795)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7886)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1041)
at android.view.Choreographer.doCallbacks(Choreographer.java:864)
at android.view.Choreographer.doFrame(Choreographer.java:798)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1026)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:239)
at android.app.ActivityThread.main(ActivityThread.java:7532)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:935)
W/System: A resource failed to call close.
A resource failed to call close.
W/mples.detection: type=1400 audit(0.0:44085): avc: denied { search } for name="game_mode" dev="sysfs" ino=60401 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:sysfs_tencent:s0 tclass=dir permissive=0
I/Process: Sending signal. PID: 1960 SIG: 9
Hi!
What's happened if I've trained my tiny yolo v3 with a custom setting in .cfg file?
I've change width and height, I've change anchor and threshold.
Are there any version of this convert tool for tensorflow 2?
Many thanks
Hey there,
I have successfully converted yolo.h5 to .tflite but when i integrate it with android using google's official project using TensorFlow i found buffer issue as unable to allocate mismatched buffer.
Can you please help to integrate this .tflite to android?
Thanks lot
Hi,
I would like to know your recommendation on which implementation is the most compatible with your yolov3-tf to tflite conversion, i am aware of the following, please let me know if you have others
https://github.com/YunYang1994/tensorflow-yolov3 ? https://github.com/AlexeyAB/darknet ?
trying to convert .weight to .pb
Traceback (most recent call last):
File "convert_weights_pb.py", line 5, in
import yolo_v3
File "/home/de-gpu-005/joel/tensorflow-lite-YOLOv3/yolo_v3.py", line 6, in
slim = tf.contrib.slim
AttributeError: module 'tensorflow' has no attribute 'contrib'
Please help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.