hunglc007 / tensorflow-yolov4-tflite

YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
https://github.com/hunglc007/tensorflow-yolov4-tflite
MIT License
2.24k stars 1.24k forks source link

On Converitng Custom trained yolov3 with one classes to TensorRT Getting Value Error, #317

Open anantgupta129 opened 3 years ago

anantgupta129 commented 3 years ago

I was successfully able to convert the pre trained yolov3 to tensor RT with giving great results, but when i tried to convert custom yolov3 convert|_trt.py is giving this error. The pd conversion using save_model.py was successful. I also did the necessary changes in config.py by changing the coco.names to my custom names file.

ValueError: Input 0 of node StatefulPartitionedCall/model/batch_normalization/AssignNewValue was passed float from Func/StatefulPartitionedCall/input/_4:0 incompatible with expected resource.

` Traceback (most recent call last): File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/framework/importer.py", line 496, in _import_graph_def_internal results = c_api.TF_GraphImportGraphDefWithResults( tensorflow.python.framework.errors_impl.InvalidArgumentError: Input 0 of node StatefulPartitionedCall/model/batch_normalization/AssignNewValue was passed float from Func/StatefulPartitionedCall/input/_4:0 incompatible with expected resource.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/experiotech/Documents/tensorflow-yolov4-tflite/convert_trt.py", line 100, in app.run(main) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/absl/app.py", line 303, in run _run_main(main, args) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/absl/app.py", line 251, in _run_main sys.exit(main(argv)) File "/home/experiotech/Documents/tensorflow-yolov4-tflite/convert_trt.py", line 96, in main save_trt() File "/home/experiotech/Documents/tensorflow-yolov4-tflite/convert_trt.py", line 61, in save_trt converter.convert() File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/compiler/tensorrt/trt_convert.py", line 1096, in convert frozen_func = convert_to_constants.convert_variables_to_constants_v2(func) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/framework/convert_to_constants.py", line 1076, in convert_variables_to_constants_v2 return _construct_concrete_function(func, output_graph_def, File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/framework/convert_to_constants.py", line 1001, in _construct_concrete_function new_func = wrap_function.function_from_graph_def(output_graph_def, File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/eager/wrap_function.py", line 650, in function_from_graph_def wrapped_import = wrap_function(_imports_graph_def, []) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/eager/wrap_function.py", line 621, in wrap_function func_graph.func_graph_from_py_func( File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/framework/func_graph.py", line 990, in func_graph_from_py_func func_outputs = python_func(*func_args, func_kwargs) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/eager/wrap_function.py", line 87, in call return self.call_with_variable_creator_scope(self._fn)(*args, *kwargs) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/eager/wrap_function.py", line 93, in wrapped return fn(args, kwargs) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/eager/wrap_function.py", line 648, in _imports_graph_def importer.import_graph_def(graph_def, name="") File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py", line 538, in new_func return func(*args, **kwargs) File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/framework/importer.py", line 400, in import_graph_def return _import_graph_def_internal( File "/home/experiotech/anaconda3/envs/my_env/lib/python3.9/site-packages/tensorflow/python/framework/importer.py", line 501, in _import_graph_def_internal raise ValueError(str(e)) ValueError: Input 0 of node StatefulPartitionedCall/model/batch_normalization/AssignNewValue was passed float from Func/StatefulPartitionedCall/input/_4:0 incompatible with expected resource. `

assulthoni commented 3 years ago

@anantgupta129 did you solve this problem?

anantgupta129 commented 3 years ago

@anantgupta129 did you solve this problem?

@assulthoni No i did not, instead i converted my model using tensorrt (nivida libray)