Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for batch nms and export checkpoint to frozen graph #174

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ArtificialNotImbecile
Copy link

No description provided.

@zpge
Copy link

zpge commented Nov 4, 2019

No description provided.

Thanks. It's very nice of you. But I don't think it's a good idea to include the nms into the frozen model. Because it the inference part, oen may want to adjust parameters like num_box and score. In this case, one may need to freeze a model everytime he wants to try other parameters. So maybe it's better to freeze the model till the feature maps?

@ArtificialNotImbecile
Copy link
Author

No description provided.

Thanks. It's very nice of you. But I don't think it's a good idea to include the nms into the frozen model. Because it the inference part, oen may want to adjust parameters like num_box and score. In this case, one may need to freeze a model everytime he wants to try other parameters. So maybe it's better to freeze the model till the feature maps?

You can experiment nms parameters using checkpoint files and then export the model to frozen graph. If you still want to tune nms parameters, you can set confidence score and iou threshold low and max number of detections high. You can also make your own version of frozen graph easily.

@zpge
Copy link

zpge commented Nov 4, 2019

OK. Thanks very much.

@Albert337
Copy link

thanks,it helps me?but when i want to convert pb_model to tflite_model,i get the error
`2020-07-22 14:15:08.865656: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
D:\anaconda\content\lib\site-packages\tensorflow\lite\python\lite.py:769: UserWarning: Property post_training_quantize is deprecated, please use optimizations=[Optimize.DEFAULT] instead.
" instead." % name)
2020-07-22 14:15:10.917121: 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)
2020-07-22 14:15:10.918029: I tensorflow/core/grappler/clusters/single_machine.cc:359] Starting new session
2020-07-22 14:15:15.810903: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:716] Optimization results for grappler item: graph_to_optimize
2020-07-22 14:15:15.811075: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] constant folding: Graph size after: 1234 nodes (-366), 1352 edges (-366), time = 3290.29199ms.
2020-07-22 14:15:15.811229: I tensorflow/core/grappler/optimizers/meta_optimizer.cc:718] constant folding: Graph size after: 1234 nodes (0), 1352 edges (0), time = 875.338ms.
Traceback (most recent call last):
File "D:/pycharm/project/yolo_test/pb2tflite.py", line 15, in
tflite_model=converter.convert()
File "D:\anaconda\content\lib\site-packages\tensorflow\lite\python\lite.py", line 898, in convert
**converter_kwargs)
File "D:\anaconda\content\lib\site-packages\tensorflow\lite\python\convert.py", line 404, in toco_convert_impl
input_data.SerializeToString())
File "D:\anaconda\content\lib\site-packages\tensorflow\lite\python\convert.py", line 172, in toco_convert_protos
"TOCO failed. See console for info.\n%s\n%s\n" % (stdout, stderr))
tensorflow.lite.python.convert.ConverterError: TOCO failed. See console for info.
2020-07-22 14:15:20.418363: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.418884: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.419088: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.420546: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.420803: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.421001: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Size
2020-07-22 14:15:20.422772: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "NoOp" device_type: "CPU"') for unknown op: NoOp
2020-07-22 14:15:20.422943: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "NoOp" device_type: "GPU"') for unknown op: NoOp
2020-07-22 14:15:20.423067: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_HostRecv" device_type: "GPU" host_memory_arg: "tensor"') for unknown op: _HostRecv
2020-07-22 14:15:20.423496: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_Send" device_type: "CPU"') for unknown op: _Send
2020-07-22 14:15:20.423737: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_HostRecv" device_type: "CPU"') for unknown op: _HostRecv
2020-07-22 14:15:20.423956: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_Send" device_type: "GPU"') for unknown op: _Send
2020-07-22 14:15:20.424165: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_Recv" device_type: "CPU"') for unknown op: _Recv
2020-07-22 14:15:20.424407: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_HostSend" device_type: "GPU" host_memory_arg: "tensor"') for unknown op: _HostSend
2020-07-22 14:15:20.424690: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_Recv" device_type: "GPU"') for unknown op: _Recv
2020-07-22 14:15:20.424922: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "_HostSend" device_type: "CPU"') for unknown op: _HostSend
2020-07-22 14:15:20.425166: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "WrapDatasetVariant" device_type: "CPU"') for unknown op: WrapDatasetVariant
2020-07-22 14:15:20.425485: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "WrapDatasetVariant" device_type: "GPU" host_memory_arg: "input_handle" host_memory_arg: "output_handle"') for unknown op: WrapDatasetVariant
2020-07-22 14:15:20.425801: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "UnwrapDatasetVariant" device_type: "CPU"') for unknown op: UnwrapDatasetVariant
2020-07-22 14:15:20.426067: E tensorflow/core/framework/op_kernel.cc:1426] OpKernel ('op: "UnwrapDatasetVariant" device_type: "GPU" host_memory_arg: "input_handle" host_memory_arg: "output_handle"') for unknown op: UnwrapDatasetVariant
2020-07-22 14:15:20.426399: I tensorflow/lite/toco/import_tensorflow.cc:1385] Unable to determine output type for op: Size
2020-07-22 14:15:20.426578: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Size
2020-07-22 14:15:20.426729: I tensorflow/lite/toco/import_tensorflow.cc:1385] Unable to determine output type for op: Size
2020-07-22 14:15:20.427200: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.427409: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.427662: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Size
2020-07-22 14:15:20.427897: I tensorflow/lite/toco/import_tensorflow.cc:1385] Unable to determine output type for op: Size
2020-07-22 14:15:20.428076: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Size
2020-07-22 14:15:20.428289: I tensorflow/lite/toco/import_tensorflow.cc:1385] Unable to determine output type for op: Size
2020-07-22 14:15:20.428830: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.429059: I tensorflow/lite/toco/import_tensorflow.cc:193] Unsupported data type in placeholder op: 2
2020-07-22 14:15:20.429262: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Size
2020-07-22 14:15:20.429438: I tensorflow/lite/toco/import_tensorflow.cc:1385] Unable to determine output type for op: Size
2020-07-22 14:15:20.429605: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: Size
2020-07-22 14:15:20.429831: I tensorflow/lite/toco/import_tensorflow.cc:1385] Unable to determine output type for op: Size
2020-07-22 14:15:20.430187: I tensorflow/lite/toco/import_tensorflow.cc:1336] Converting unsupported operation: CombinedNonMaxSuppression
2020-07-22 14:15:20.430424: I tensorflow/lite/toco/import_tensorflow.cc:1385] Unable to determine output type for op: CombinedNonMaxSuppression
2020-07-22 14:15:20.500764: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Removing unused ops: 818 operators, 1612 arrays (0 quantized)
2020-07-22 14:15:20.530326: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before general graph transformations: 818 operators, 1612 arrays (0 quantized)
2020-07-22 14:15:21.520400: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] After general graph transformations pass 1: 390 operators, 794 arrays (0 quantized)
2020-07-22 14:15:21.534887: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before Group bidirectional sequence lstm/rnn: 390 operators, 794 arrays (0 quantized)
2020-07-22 14:15:21.546578: I tensorflow/lite/toco/graph_transformations/graph_transformations.cc:39] Before dequantization graph transformations: 390 operators, 794 arrays (0 quantized)
2020-07-22 14:15:21.558956: F tensorflow/lite/toco/allocate_transient_arrays.cc:180] An array, truediv/Cast, still does not have a known data type after all graph transformations have run.
Fatal Python error: Aborted

Current thread 0x000013f8 (most recent call first):
File "d:\anaconda\content\lib\site-packages\tensorflow\lite\toco\python\toco_from_protos.py", line 33 in execute
File "d:\anaconda\content\lib\site-packages\absl\app.py", line 250 in run_main
File "d:\anaconda\content\lib\site-packages\absl\app.py", line 299 in run
File "d:\anaconda\content\lib\site-packages\tensorflow\python\platform\app.py", line 40 in run
File "d:\anaconda\content\lib\site-packages\tensorflow\lite\toco\python\toco_from_protos.py", line 59 in main
File "D:\anaconda\content\Scripts\toco_from_protos.exe_main
.py", line 7 in
File "d:\anaconda\content\lib\runpy.py", line 85 in _run_code
File "d:\anaconda\content\lib\runpy.py", line 193 in _run_module_as_main

Process finished with exit code 1
`,and i try to slove it but failed,is there any advice for me? @zpge @wizyoung @luoyx @cloudrivers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants