MPolaris / onnx2tflite

Tool for onnx->keras or onnx->tflite. Hope this tool can help you.
Apache License 2.0
507 stars 41 forks source link

Error: variable referenced before assignment #7

Closed nasircsms closed 2 years ago

nasircsms commented 2 years ago

Hi Trying to convert Yolov7 but getting following error

Traceback (most recent call last): File "converter.py", line 64, in run() File "converter.py", line 60, in run image_root=opt.imgroot File "converter.py", line 16, in onnx_converter keras_model = keras_builder(model_proto) File "/yolo/v7/onnx2tflite-main/utils/builder.py", line 84, in keras_builder tf_tensor[node_outputs[index]] = tf_operator(tf_tensor, onnx_weights, node_inputs, op_attr, index=index)(_inputs) File "/yolo/v7/onnx2tflite-main/layers/common_layers.py", line 290, in call inputs[i] = tf.cast(inputs, dtype=self.tf_cast_map[self.cast_to]) UnboundLocalError: local variable 'i' referenced before assignment

MPolaris commented 2 years ago

oops, it's a bug, you can change 'inputs[i]'(line 288 and 290) in common_layers.py to 'inputs' by yourself, or waiting my updates

MPolaris commented 2 years ago

But, Cast op was not used in yolov7, maybe you can set 'need_simplify=True' or 'python converter.py --simplify'