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

Converting YoloV5s to Pb file failed #4

Open
kaldarabsah opened this issue Jul 27, 2020 · 7 comments
Open

Converting YoloV5s to Pb file failed #4

kaldarabsah opened this issue Jul 27, 2020 · 7 comments

Comments

@kaldarabsah
Copy link

I am getting this error message when I convert yolov5s.pt to pb file

Traceback (most recent call last):
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1607, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Depth of input (16) is not a multiple of input depth of filter (512) for 'conv_route4/Conv2D' (op: 'Conv2D') with input shapes: [?,?,?,16], [1,1,512,256].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/kaldarabsah/Downloads/Yolov5_tf/core/yolov5.py", line 170, in init
self.conv_lbbox, self.conv_mbbox, self.conv_sbbox = self.__build_network(input_data)
File "/Users/kaldarabsah/Downloads/Yolov5_tf/core/yolov5.py", line 199, in __build_network
y19, layer_num = cspstage(input_data, self.trainable, 16init_width_size, init_depth_size, layer_num, 4, 1+7init_depth_size)
File "/Users/kaldarabsah/Downloads/Yolov5_tf/core/yolov5.py", line 92, in cspstage
route = conv(route, (1, 1, c, c / 2), trainable=trainable, name='conv_route%d' % route_nums, act_fun='mish')
File "/Users/kaldarabsah/Downloads/Yolov5_tf/core/yolov5.py", line 33, in conv
conv = tf.nn.conv2d(input=input_data, filter=weight, strides=strides, padding=padding)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/ops/nn_ops.py", line 2010, in conv2d
name=name)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_nn_ops.py", line 1071, in conv2d
data_format=data_format, dilations=dilations, name=name)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/framework/op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1770, in init
control_input_ops)
File "/opt/miniconda2/envs/airflow/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 1610, in _create_c_op
raise ValueError(str(e))
ValueError: Depth of input (16) is not a multiple of input depth of filter (512) for 'conv_route4/Conv2D' (op: 'Conv2D') with input shapes: [?,?,?,16], [1,1,512,256].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "from_darknet_weights_to_pb.py", line 18, in
model = YOLOV5(input_data, trainable=False)
File "/Users/kaldarabsah/Downloads/Yolov5_tf/core/yolov5.py", line 172, in init
raise NotImplementedError('Can not build up yolov5 network')
NotImplementedError: Can not build up yolov5 network

Kindly, add an example how to convert pt file to pb

Thank you.

@avBuffer
Copy link
Owner

OK, Tks! I try it.

@kaldarabsah
Copy link
Author

Did it work for YoloV5s.pt file?

@NanoCode012
Copy link

NanoCode012 commented Jul 31, 2020

@kaldarabsah @avBuffer , hello, as I see it, the convert script from_darknet_weights_to_pb.py only works from .weights to .pb right? How can we use a .pt file?

From #2 (comment), you recommended to convert to onnx to tf. Can you recommend me a repo? We have to convert from onnx to tf1 right, not tf2?

@kaldarabsah
Copy link
Author

@NanoCode012 . I tried to add YoloV5 to the script but when I ran it, it did not work.
https://github.com/avBuffer/Yolov5_tf/blob/master/scripts/from_darknet_weights_to_pb.py#L3

YoloV5 only has pt file. Here are the weights for Yolov5 from the original repo https://drive.google.com/drive/folders/1Drs_Aiu7xx6S-ix95f9kNsA6ueKRpN2J

@NanoCode012
Copy link

NanoCode012 commented Jul 31, 2020

@NanoCode012 . I tried to add YoloV5 to the script but when I ran it, it did not work.
https://github.com/avBuffer/Yolov5_tf/blob/master/scripts/from_darknet_weights_to_pb.py#L3

@kaldarabsah Yes, because when I read it, it does not convert yolov5. Only darknet .weights.

darknet_weights = 'model_data/yolov4.weights'

@avBuffer
Copy link
Owner

Hey kaldarabsah, Thanks! I fixed the error, you can try it!

@lengyuner
Copy link

@kaldarabsah
hi, where did you get the yolov5.weight, the link is invalid.

TFT

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

No branches or pull requests

4 participants