Comments (7)
absolutely yes !
from tensorflow2.0-examples.
@YunYang1994 would you be so kind to point me into the right direction. I created a simple python script to do the conversion, but its failing with a Fatal Python error.
import tensorflow as tf
from core.yolov3 import YOLOv3, decode
def representative_dataset_gen():
for _ in range(num_calibration_steps):
# Get sample input data as a numpy array in a method of your choosing.
yield [input]
input_size = 416
input_layer = tf.keras.layers.Input([input_size, input_size, 3])
feature_maps = YOLOv3(input_layer)
bbox_tensors = []
for i, fm in enumerate(feature_maps):
bbox_tensor = decode(fm, i)
bbox_tensors.append(bbox_tensor)
model = tf.keras.Model(input_layer, bbox_tensors)
utils.load_weights(model, "./yolov3.weights")
model.summary()
# Create a converter
converter = tf.lite.TFLiteConverter.from_keras_model(model)
# Convert the model
# converter.optimizations = [tf.lite.Optimize.DEFAULT]
# converter.representative_dataset = representative_dataset_gen
# converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
# converter.inference_input_type = tf.uint8
# converter.inference_output_type = tf.uint8
tflite_model = converter.convert()
# Create the tflite model file
tflite_model_name = "yolov3.tflite"
open(tflite_model_name, "wb").write(tflite_model)
The exception is:
2019-12-04 22:44:51.903243: I tensorflow/core/grappler/devices.cc:60] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA support)
2019-12-04 22:44:51.903322: I tensorflow/core/grappler/clusters/single_machine.cc:356] Starting new session
2019-12-04 22:44:51.956138: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:716] Optimization results for grappler item: graph_to_optimize
2019-12-04 22:44:51.956163: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] function_optimizer: function_optimizer did nothing. time = 0.007ms.
2019-12-04 22:44:51.956170: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] function_optimizer: function_optimizer did nothing. time = 0ms.
2019-12-04 22:45:00.864649: I tensorflow/core/grappler/devices.cc:60] Number of eligible GPUs (core count >= 8, compute capability >= 0.0): 0 (Note: TensorFlow was not compiled with CUDA support)
2019-12-04 22:45:00.864756: I tensorflow/core/grappler/clusters/single_machine.cc:356] Starting new session
2019-12-04 22:45:06.669028: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:716] Optimization results for grappler item: graph_to_optimize
2019-12-04 22:45:06.669057: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] constant folding: Graph size after: 884 nodes (-370), 2039 edges (-370), time = 3086.21191ms.
2019-12-04 22:45:06.669063: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] constant folding: Graph size after: 884 nodes (0), 2039 edges (0), time = 1459.73096ms.
Traceback (most recent call last):
File "convert.py", line 34, in <module>
tflite_model = converter.convert()
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/tensorflow_core/lite/python/lite.py", line 446, in convert
**converter_kwargs)
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/tensorflow_core/lite/python/convert.py", line 449, in toco_convert_impl
enable_mlir_converter=enable_mlir_converter)
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/tensorflow_core/lite/python/convert.py", line 200, in toco_convert_protos
raise ConverterError("See console for info.\n%s\n%s\n" % (stdout, stderr))
tensorflow.lite.python.convert.ConverterError: See console for info.
2019-12-04 22:45:13.865417: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 652 operators, 1247 arrays (0 quantized)
2019-12-04 22:45:13.878738: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 652 operators, 1247 arrays (0 quantized)
2019-12-04 22:45:14.705331: F tensorflow/lite/toco/graph_transformations/resolve_strided_slice_attributes.cc:95] Check failed: start_indices_size <= num_input_axes (2 vs. 1)StridedSlice op requires no more than 1 start indices
Fatal Python error: Aborted
Current thread 0x000000010a9855c0 (most recent call first):
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/tensorflow_core/lite/toco/python/toco_from_protos.py", line 57 in execute
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/absl/app.py", line 250 in _run_main
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/absl/app.py", line 299 in run
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/tensorflow_core/python/platform/app.py", line 40 in run
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/lib/python3.7/site-packages/tensorflow_core/lite/toco/python/toco_from_protos.py", line 94 in main
File "/workspace/sandbox/TensorFlow2.0-Examples/4-Object_Detection/YOLOV3/venv3/bin/toco_from_protos", line 10 in <module>
I played around and with different options for the converter, but without much success.
# converter.optimizations = [tf.lite.Optimize.DEFAULT]
# converter.representative_dataset = representative_dataset_gen
# converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
# converter.inference_input_type = tf.uint8
# converter.inference_output_type = tf.uint8
And bear in mind that ML is completely new to me. 😄
Would appreciate some help, thanks
from tensorflow2.0-examples.
@YunYang1994 hey, sorry to bother you again, but would really appreciate some help
from tensorflow2.0-examples.
hello @YunYang1994, would really appreciate some help
from tensorflow2.0-examples.
@YunYang1994 any help?
from tensorflow2.0-examples.
up @YunYang1994
from tensorflow2.0-examples.
Try this: https://github.com/guichristmann/edge-tpu-tiny-yolo 👍
from tensorflow2.0-examples.
Related Issues (20)
- Can we train with multiple scale training procedure? HOT 1
- anxious for transformer
- 请问大家是怎么自制数据集的呢 HOT 1
- 为什么这里没有开启多尺度训练了?
- 关于 postprocess_boxes(pred_bbox, org_img_shape, input_size, score_threshold)
- test.py nan HOT 2
- 运行test.py只有第一张图片有测试结果,剩下的图片都没有检测框出现 HOT 3
- 请问如何计算FLOPs?
- InvalidArgumentError: ConcatOp : Dimensions of inputs should match: shape[0] = [2704,54] vs. shape[1] = [8112,18] [Op:ConcatV2] name: concat
- YOLOv3 model doesn't converge HOT 7
- Confused about convolutional layer implementation in YOLOv3
- 关于SSD卷积代替全连接层的请教
- Question about the image_preprocess function
- 本人小白,请教迁移学习,初始化权重训练自己的数据!
- Problem about ResNet.
- 运行video_demo.py时,只有第一帧预测正确后面都是nan,也就是后面没有预测框 HOT 1
- yolov3 mAP on PASCAL VOC2012
- Error when training with my own dataset using train.py: Failed to get convolution algorithm.
- 请问为什么求conf_loss和prob_loss时的logits用的是feature map的输出而不用decode后得到的概率值,感谢!
- 这个没有download怎么下载
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 tensorflow2.0-examples.