tensorflow / tensorflow/models
The error about convert ssd mobilenet v2 coco models into tflite model.
@pkulzc is already working on this.
Since Jun 4, 2020.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
I need to convert ssd_mobilenet_v2_coco model into tflite model.
I searched the web, and I didn't get a viable answer.
I used tf version is 1.13 and 1.15 .It has same error
Method 1: via command line
tflite_convert --output_file=ssdMobile2.tflite --graph_def_file=ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb --input_arrays=image_tensor --output_arrays=detection_boxes,detection_scores,num_detections,detection_classes
the error message:
2020-01-15 23:57:30.550956: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
Traceback (most recent call last):
File "/root/anaconda3/envs/tf_1.15_cpu/bin/tflite_convert", line 8, in
sys.exit(main())
File "/root/anaconda3/envs/tf_1.15_cpu/lib/python3.6/site-packages/tensorflow_core/lite/python/tflite_convert.py", line 515, in main
app.run(main=run_main, argv=sys.argv[:1])
File "/root/anaconda3/envs/tf_1.15_cpu/lib/python3.6/site-packages/tensorflow_core/python/platform/app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "/root/anaconda3/envs/tf_1.15_cpu/lib/python3.6/site-packages/absl/app.py", line 299, in run
_run_main(main, args)
File "/root/anaconda3/envs/tf_1.15_cpu/lib/python3.6/site-packages/absl/app.py", line 250, in _run_main
sys.exit(main(argv))
File "/root/anaconda3/envs/tf_1.15_cpu/lib/python3.6/site-packages/tensorflow_core/lite/python/tflite_convert.py", line 511, in run_main
_convert_tf1_model(tflite_flags)
File "/root/anaconda3/envs/tf_1.15_cpu/lib/python3.6/site-packages/tensorflow_core/lite/python/tflite_convert.py", line 199, in _convert_tf1_model
output_data = converter.convert()
File "/root/anaconda3/envs/tf_1.15_cpu/lib/python3.6/site-packages/tensorflow_core/lite/python/lite.py", line 896, in convert
_get_tensor_name(tensor), shape_list))
ValueError: None is only supported in the 1st dimension. Tensor 'image_tensor' has invalid shape '[None, None, None, 3]'.
Method 2: via Python API
import tensorflow as tf
graph_def_file = "/data/models/ssdlite_mobilenet_v2_coco_2018_05_09/frozen_inference_graph.pb"
input_arrays = ["image_tensor"]
output_arrays = ["detection_boxes","detection_scores","num_detections","detection_classes"]
converter = tf.lite.TFLiteConverter.from_frozen_graph(graph_def_file, input_arrays, output_arrays)
converter = tf.lite.TFLiteConverter.from_frozen_graph(graph_def_file, input_arrays, output_arrays, input_shapes={'image_tensor': [1, 300, 300, 3]})
tflite_model = converter.convert()
This is the error:
2020-01-15 23:41:03.884504: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After Removing unused ops pass 1: 4311 operators, 7077 arrays (0 quantized) 2020-01-15 23:41:04.700810: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 4311 operators, 7077 arrays (0 quantized) 2020-01-15 23:41:05.290222: F ./tensorflow/lite/toco/toco_tooling.h:38] Check failed: s.ok() Found StridedSlice as non-selected output from Switch, but only Merge supported. Control flow ops like Switch and Merge are not generally supported. We are working on fixing this, please see the Github issue at https://github.com/tensorflow/tensorflow/issues/28485. Fatal Python error: Aborted
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.