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

YoloV3_V4_tiny_training.ipynb - convert_weights_pb.py error: Cannot convert a symbolic Tensor (detector/yolo-v4-tiny/meshgrid/Size_1:0) to a numpy array. #22

Open
itsderek23 opened this issue Mar 24, 2022 · 3 comments
Assignees

Comments

@itsderek23
Copy link

itsderek23 commented Mar 24, 2022

The following cell:

!python3 convert_weights_pb.py \
--yolo $yolo_version \
--weights_file $weights_best \
--class_names /content/obj.names \
--output $output_name_pb \
--tiny \
-h 320 \
-w 512

Fails w/the output below:

!python3 convert_weights_pb.py \
--yolo $yolo_version \
--weights_file $weights_best \
--class_names /content/obj.names \
--output $output_name_pb \
--tiny \
-h 320 \
-w 512
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
  * https://github.com/tensorflow/addons
  * https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.

WARNING:tensorflow:From convert_weights_pb.py:94: The name tf.app.run is deprecated. Please use tf.compat.v1.app.run instead.

None
WARNING:tensorflow:From convert_weights_pb.py:68: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0323 14:01:30.138594 140253906458496 module_wrapper.py:139] From convert_weights_pb.py:68: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

WARNING:tensorflow:From convert_weights_pb.py:76: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

W0323 14:01:30.147910 140253906458496 module_wrapper.py:139] From convert_weights_pb.py:76: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.

WARNING:tensorflow:From /tensorflow-1.15.2/python3.7/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
W0323 14:01:30.156273 140253906458496 deprecation.py:323] From /tensorflow-1.15.2/python3.7/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use `layer.__call__` method instead.
Traceback (most recent call last):
  File "convert_weights_pb.py", line 94, in <module>
    tf.app.run()
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/platform/app.py", line 40, in run
    _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
  File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 312, in run
    _run_main(main, args)
  File "/usr/local/lib/python3.7/dist-packages/absl/app.py", line 258, in _run_main
    sys.exit(main(argv))
  File "convert_weights_pb.py", line 77, in main
    detections = model(inputs, len(classes), anchors, data_format=FLAGS.data_format)
  File "/content/yolo2openvino/models/yolo_v4_tiny.py", line 87, in yolo_v4_tiny
    net, num_classes, anchors[3:6], img_size, data_format)
  File "/content/yolo2openvino/models/common.py", line 79, in _detection_layer
    a, b = tf.meshgrid(grid_x, grid_y)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/array_ops.py", line 2943, in meshgrid
    mult_fact = ones(shapes, output_dtype)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/array_ops.py", line 2560, in ones
    output = _constant_if_small(one, shape, dtype, name)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/ops/array_ops.py", line 2295, in _constant_if_small
    if np.prod(shape) < 1000:
  File "<__array_function__ internals>", line 6, in prod
  File "/usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py", line 3052, in prod
    keepdims=keepdims, initial=initial, where=where)
  File "/usr/local/lib/python3.7/dist-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
  File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/framework/ops.py", line 736, in __array__
    " array.".format(self.name))
NotImplementedError: Cannot convert a symbolic Tensor (detector/yolo-v4-tiny/meshgrid/Size_1:0) to a numpy array.

I'm running on Google Colab. Here is a gist of the notebook output.

@tersekmatija
Copy link
Contributor

Hey @itsderek23 ,

Could you try adding this at the top of the notebook and see if it resolves the issue?

!pip install numpy==1.16.6
!pip install tensorflow==1.14.0
!pip install openvino==2021.3

Colab automatically updates version of libraries, and it might break some things over time. I'll make sure to add those to the notebooks.

@itsderek23
Copy link
Author

Thanks. Looks like downgrading numpy causes a conflict w/pandas:

import pandas as pd
import numpy as np
# colnames are wrong so we have to fix them
colnames=['xmin', 'ymin', 'xmax', 'ymax', 'frame', 'label', 'preview'] 
df = pd.read_csv(f"{ds_path}/labels.csv")
df.rename(columns = {"xmax":"ymin", "ymin":"xmax"}, inplace = True)

filter_categories = ["Car"]
df = df[df['Label'].str.contains("|".join(filter_categories))]
df.head()
     25 if _nlv < Version(_min_numpy_ver):
     26     raise ImportError(
---> 27         f"this version of pandas is incompatible with numpy < {_min_numpy_ver}\n"
     28         f"your numpy version is {_np_version}.\n"
     29         f"Please upgrade numpy to >= {_min_numpy_ver} to use this pandas version"

ImportError: this version of pandas is incompatible with numpy < 1.17.3
your numpy version is 1.16.6.
Please upgrade numpy to >= 1.17.3 to use this pandas version

@tersekmatija
Copy link
Contributor

Adding this at the top and restarting runtime works for me. Can you confirm? @itsderek23 Then I'll update the notebook.

!pip uninstall numpy -y
!pip uninstall pandas -y
!pip uninstall tensorflow -y
!pip install numpy==1.16.6
!pip install pandas==1.2.1
!pip install tensorflow==1.14.0

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

2 participants