Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android TOCO无法使用--allow_custom_ops转换不支持的操作_Android_Tensorflow_Tensorflow Lite_Toco - Fatal编程技术网

Android TOCO无法使用--allow_custom_ops转换不支持的操作

Android TOCO无法使用--allow_custom_ops转换不支持的操作,android,tensorflow,tensorflow-lite,toco,Android,Tensorflow,Tensorflow Lite,Toco,我正在尝试转换在pascal voc数据集()上训练的mobilenet_v2模型 我想以1024x1024分辨率推断,因此我使用以下命令导出了模型 python export_model.py \ --checkpoint_path model/model.ckpt-30000 \ --export_path ./frozen_inference_graph.pb \ --model_variant="mobilenet_v2" \ --num_classes=21 \ --crop_siz

我正在尝试转换在pascal voc数据集()上训练的mobilenet_v2模型

我想以1024x1024分辨率推断,因此我使用以下命令导出了模型

 python export_model.py \
--checkpoint_path model/model.ckpt-30000 \
--export_path ./frozen_inference_graph.pb \
--model_variant="mobilenet_v2" \
--num_classes=21 \
--crop_size=1024 \
--crop_size=1024 \
--inference_scales=1.0
然后我使用toco命令将模型转换为tflite

toco --graph_def_file=/home/abdullah/models-master/research   /frozen_casted.pb --input_format=TENSORFLOW_GRAPHDEF                                                         

--output_format=TFLITE  

--output_file=deeplabv3_mnv2_pascal_trainval.tflite   
--inference_type=FLOAT --inference_input_type=QUANTIZED_UINT8
--input_arrays=ImageTensor 
--output_arrays=SemanticPredictions
--input_shapes=1,1024,1024,3 --default_ranges_min=0 
--default_ranges_max=255 --allow_custom_ops  
--std_dev_values=128 --mean_values=1
然后将模型转换为tflite,无错误:

    2019-07-16 00:28:18.188009: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1171] Converting unsupported operation: Equal
2019-07-16 00:28:18.188052: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1171] Converting unsupported operation: Equal
2019-07-16 00:28:18.188067: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1171] Converting unsupported operation: LogicalOr
2019-07-16 00:28:18.188093: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1171] Converting unsupported operation: Unpack
2019-07-16 00:28:18.188134: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1171] Converting unsupported operation: LogicalAnd
2019-07-16 00:28:18.192256: I tensorflow/contrib/lite/toco/import_tensorflow.cc:1171] Converting unsupported operation: ResizeNearestNeighbor
2019-07-16 00:28:18.203603: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 813 operators, 1237 arrays (0 quantized)
2019-07-16 00:28:18.232795: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After Removing unused ops pass 1: 801 operators, 1215 arrays (0 quantized)
2019-07-16 00:28:18.269909: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 801 operators, 1215 arrays (0 quantized)
2019-07-16 00:28:18.293777: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 1: 132 operators, 325 arrays (0 quantized)
2019-07-16 00:28:18.296414: I tensorflow/contrib/lite/toco/graph_transformations/graph_transformations.cc:39] Before dequantization graph transformations: 132 operators, 325 arrays (0 quantized)
2019-07-16 00:28:18.298905: I tensorflow/contrib/lite/toco/allocate_transient_arrays.cc:311] Total transient array allocated size: 28311552 bytes, theoretical optimal value: 25165824 bytes.
2019-07-16 00:28:18.299732: W tensorflow/contrib/lite/toco/tflite/operator.cc:661] Ignoring unsupported attribute type with key '_output_shapes'
2019-07-16 00:28:18.299743: W tensorflow/contrib/lite/toco/tflite/operator.cc:661] Ignoring unsupported attribute type with key 'T'
2019-07-16 00:28:18.299946: W tensorflow/contrib/lite/toco/tflite/operator.cc:661] Ignoring unsupported attribute type with key 'T'
2019-07-16 00:28:18.299956: W tensorflow/contrib/lite/toco/tflite/operator.cc:661] Ignoring unsupported attribute type with key '_output_shapes'
但是,当我在tflite上运行模型时,它给出了以下错误

java.lang.IllegalArgumentException:内部错误:无法创建解释器:找不到版本为1的名称“ExpandDims”的自定义op 注册失败

对于转换,我使用了tensorflowtensorflow=='1.6.0-rc1'

build.gradle中的tflite实现是实现“org.tensorflow:tensorflow lite:+”


我不知道我在哪里失败了,请帮助我。

--允许自定义操作
被添加到tf1.10中,请参见,但tf1.10非常旧,无法将模型转换为tflite“nodedf在Op y:DstT中提到attr'Truncate”;attr=SrcT:type;attr=DstT:type>;nodedf:Cast=Cast[DstT\u FLOAT,SrcT=DT\u UINT8,Truncate=false,_output\u shapes=[?,?,3]](挤压)。(检查GraphDef解释二进制文件是否与GraphDef生成二进制文件一起处于最新状态。)我的意思是它在TF 1.10和更高版本中可用。我知道您使用的是TF 1.6,它比TF 1.6旧得多。我建议使用TF nightly将模型转换为TF-lite。ExpandDims现在作为TensorFlow lite的适当内置操作受到支持。我将更新您的TensorFlow版本(用于转换模型)至少到1.14.0。tf1.10中添加了“允许自定义操作”,请参见,但tf1.10非常旧,无法将模型转换为tflite“NodeDef在Op y:DstT中提到attr‘Truncate’;attr=SrcT:type;attr=DstT:type>;NodeDef:Cast=Cast[DstT=DT\u FLOAT,SrcT=DT\u UINT8,Truncate=false,[u output\u shapes=[?,?,3]](挤压)。(检查GraphDef解释二进制文件是否与GraphDef生成二进制文件一起处于最新状态。)我的意思是它在TF 1.10和更高版本中可用。我知道您使用的是TF 1.6,它比TF 1.6旧得多。我建议您使用TF nightly将模型转换为TF-lite。ExpandDims现在作为TensorFlow lite的适当内置操作受到支持。我会将您的TensorFlow版本(用于转换模型)更新为至少1.14.0。