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

TypeError: unhashable type: 'list'. When running "model_builder_tf2_test.py" #11161

Open
RodasPneus opened this issue Feb 13, 2024 · 8 comments
Assignees
Labels
models:research models that come under research directory type:bug Bug in the code

Comments

@RodasPneus
Copy link

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [ x] I am using the latest TensorFlow Model Garden release and TensorFlow 2.
  • [ x] I am reporting the issue to the correct repository. (Model Garden official or research directory)
  • [x ] I checked to make sure that this issue has not been filed already.

1. The entire URL of the file you are using

https://github.com/tensorflow/models/blob/master/research/object_detection/builders/model_builder_tf2_test.py

2. Describe the bug

Whenever I run the file I get the following error:

2024-02-13 17:26:05.504018: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
Traceback (most recent call last):
  File "C:\programacao\CNN-JUPYTER\TFODCourse\Tensorflow\models\research\object_detection\builders\model_builder_tf2_test.py", line 21, in <module>
    import tensorflow.compat.v1 as tf
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\__init__.py", line 45, in <module>
    from tensorflow._api.v2 import __internal__
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\__internal__\__init__.py", line 8, in <module>
    from tensorflow._api.v2.__internal__ import autograph
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\__internal__\autograph\__init__.py", line 8, in <module>
    from tensorflow.python.autograph.core.ag_ctx import control_status_ctx # line: 34
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\autograph\core\ag_ctx.py", line 21, in <module>
    from tensorflow.python.autograph.utils import ag_logging
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\autograph\utils\__init__.py", line 17, in <module>
    from tensorflow.python.autograph.utils.context_managers import control_dependency_on_returns
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\autograph\utils\context_managers.py", line 19, in <module>
    from tensorflow.python.framework import ops
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\framework\ops.py", line 5906, in <module>
    ) -> Optional[Callable[[Any], message.Message]]:
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 262, in inner
    return func(*args, **kwds)
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 339, in __getitem__
    return self._getitem(self, parameters)
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 463, in Optional
    return Union[arg, type(None)]
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 262, in inner
    return func(*args, **kwds)
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 339, in __getitem__
    return self._getitem(self, parameters)
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 451, in Union
    parameters = _remove_dups_flatten(parameters)
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 231, in _remove_dups_flatten
    return tuple(_deduplicate(params))
  File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\typing.py", line 205, in _deduplicate
    all_params = set(params)
TypeError: unhashable type: 'list'

3. Steps to reproduce

Clone the repo and run the file

4. Expected behavior

The file should run the tests without any errors

5. Additional context

This has been happening for a while with the file: https://github.com/tensorflow/models/blob/master/research/object_detection/model_main_tf2.py
I reinstalled everything and ran the file in a virtual environment to see if it fixed itself and it didn't. This error happens with both the est file and the normal file.

6. System information

  • Windows 10 22H2 19045.3930
  • Mobile device name if the issue happens on a mobile device:
  • TensorFlow installed from binary
  • TensorFlow version (use command below): 2.15.0
  • Python version: 3.9.1
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: Not using
  • GPU model and memory: Not using
@RodasPneus RodasPneus added models:official models that come under official repository type:bug Bug in the code labels Feb 13, 2024
@laxmareddyp laxmareddyp added models:research models that come under research directory and removed models:official models that come under official repository labels Feb 13, 2024
@laxmareddyp
Copy link
Collaborator

Hi @RodasPneus ,

Thanks for reaching out here, but it is happening with research repository code as it is not having much development now a days.
I strongly suggest utilizing the TensorFlow Official Model Garden to circumvent issues related to outdated code commonly found in research codebases. Unlike the research repositories, the Official Model Garden is consistently updated and aligned with the latest changes in TensorFlow and other libraries and there are lot of API's are available that you can define a training experiment using Python commands in the TensorFlow Model library.

@laxmareddyp laxmareddyp added the stat:awaiting response Waiting on input from the contributor label Feb 13, 2024
@RodasPneus
Copy link
Author

Thank you for answering, do you think that downgrading tensorflow would work?

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting on input from the contributor label Feb 13, 2024
@laxmareddyp
Copy link
Collaborator

Hi @RodasPneus ,

I am not sure whether it works are not since the research code base is not aligned with the latest changes in TF Framework and there are few libraries deprecated time to time with the new releases in TF.But I suggest you try with downgrading Tensorflow and see if it works. I would like you to move on to official Model Garden repo to work with latest changes in your code.

Thanks.

@laxmareddyp laxmareddyp added the stat:awaiting response Waiting on input from the contributor label Feb 13, 2024
@RodasPneus
Copy link
Author

RodasPneus commented Feb 15, 2024

I'm sorry to bother you again, I managed to fix the previous issue by downgrading tensorflow to 2.5.0, and by changing some stuff inside of the object_detection library to be able to use tf.contrib.slim, however the following lines

from object_detection.meta_architectures import deepmac_meta_arch
from object_detection.models import center_net_hourglass_feature_extractor
from object_detection.models.keras_models import hourglass_network
from object_detection.protos import center_net_pb2
from object_detection.protos import model_pb2
from object_detection.utils import tf_version

Now give me errors like this

    from object_detection.meta_architectures import deepmac_meta_arch
ImportError: cannot import name 'deepmac_meta_arch' from 'object_detection.meta_architectures' (C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\object_detection\meta_architectures\__init__.py)

Do you have any idea on how to solve this?

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting on input from the contributor label Feb 15, 2024
@laxmareddyp
Copy link
Collaborator

Hi @RodasPneus ,

No, not at all, Happy to help you.!

It seems like there might be compatibility issues or changes in the object detection library you're using.Make sure that the object detection library is correctly installed in your environment. Sometimes, incomplete installations(since you are downgrading the TF version) or corruption during installation can lead to such errors.Also i suggest you to try with TF2.6.0 version to see if this error disappears.

But working with old Versions of TF would lead to these kind of errors due to deprecation the libraries or renaming the libraries.

Thanks

@laxmareddyp laxmareddyp added the stat:awaiting response Waiting on input from the contributor label Feb 15, 2024
@RodasPneus
Copy link
Author

Thank you, for some reason I didn't have some of the files downloaded. I have now solved that error and some more errors. However I now get the following error:
Traceback (most recent call last): File "C:\programacao\CNN-JUPYTER\TFODCourse\Tensorflow\models\research\object_detection\builders\model_builder_tf2_test.py", line 27, in <module> from object_detection.meta_architectures import deepmac_meta_arch File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\object_detection\meta_architectures\deepmac_meta_arch.py", line 21, in <module> from object_detection.protos import center_net_pb2 File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\object_detection\protos\center_net_pb2.py", line 21, in <module> DESCRIPTOR = _descriptor.FileDescriptor( File "C:\Users\rodri\AppData\Local\Programs\Python\Python39\lib\site-packages\google\protobuf\descriptor.py", line 1024, in __new__ return _message.default_pool.AddSerializedFile(serialized_pb) TypeError: Couldn't build proto file into descriptor pool! Invalid proto descriptor for file "object_detection/protos/center_net.proto": object_detection.protos.CenterNet.DeepMACMaskEstimation.jitter_mode: ".object_detection.protos.RandomJitterBoxes.JitterMode" is not defined.
I cannot find anything about this error online.
I have downloaded the right files and ran them through the !protoc --python_out=. command

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting on input from the contributor label Feb 15, 2024
@laxmareddyp
Copy link
Collaborator

Hi @RodasPneus ,

The error showing undefined type object_detection.protos.RandomJitterBoxes.JitterMode.
Inspect the center_net.proto file and RandomJitterBoxes and JitterMode are defined and imported properly.
Please check that you've correctly compiled the protobuf files using above command and generated Python files are located in the expected directory.

Thanks

@laxmareddyp laxmareddyp added the stat:awaiting response Waiting on input from the contributor label Feb 15, 2024
@RodasPneus
Copy link
Author

I have checked and everything is correct. Is there anyway to get the _pb2.py files without compiling them myself to make sure they're right? My .proto files are the same as in the repo, but I noticed that RandomJitterboxes gets exported while Jittermode doesn't. Is this supposed to happen? Here is the code: export RandomJitterBoxes // Message for defining a preprocessing operation on input data. // See: //third_party/tensorflow_models/object_detection/core/preprocessor.py // Next ID: 41 message PreprocessingStep { oneof preprocessing_step { NormalizeImage normalize_image = 1; RandomHorizontalFlip random_horizontal_flip = 2; RandomPixelValueScale random_pixel_value_scale = 3; RandomImageScale random_image_scale = 4; RandomRGBtoGray random_rgb_to_gray = 5; RandomAdjustBrightness random_adjust_brightness = 6; RandomAdjustContrast random_adjust_contrast = 7; RandomAdjustHue random_adjust_hue = 8; RandomAdjustSaturation random_adjust_saturation = 9; RandomDistortColor random_distort_color = 10; RandomJitterBoxes random_jitter_boxes = 11; RandomCropImage random_crop_image = 12; RandomPadImage random_pad_image = 13; RandomCropPadImage random_crop_pad_image = 14; RandomCropToAspectRatio random_crop_to_aspect_ratio = 15; RandomBlackPatches random_black_patches = 16; RandomResizeMethod random_resize_method = 17; ScaleBoxesToPixelCoordinates scale_boxes_to_pixel_coordinates = 18; ResizeImage resize_image = 19; SubtractChannelMean subtract_channel_mean = 20; SSDRandomCrop ssd_random_crop = 21; SSDRandomCropPad ssd_random_crop_pad = 22; SSDRandomCropFixedAspectRatio ssd_random_crop_fixed_aspect_ratio = 23; SSDRandomCropPadFixedAspectRatio ssd_random_crop_pad_fixed_aspect_ratio = 24; RandomVerticalFlip random_vertical_flip = 25; RandomRotation90 random_rotation90 = 26; RGBtoGray rgb_to_gray = 27; ConvertClassLogitsToSoftmax convert_class_logits_to_softmax = 28; RandomAbsolutePadImage random_absolute_pad_image = 29; RandomSelfConcatImage random_self_concat_image = 30; AutoAugmentImage autoaugment_image = 31; DropLabelProbabilistically drop_label_probabilistically = 32; RemapLabels remap_labels = 33; RandomJpegQuality random_jpeg_quality = 34; RandomDownscaleToTargetPixels random_downscale_to_target_pixels = 35; RandomPatchGaussian random_patch_gaussian = 36; RandomSquareCropByScale random_square_crop_by_scale = 37; RandomScaleCropAndPadToSquare random_scale_crop_and_pad_to_square = 38; AdjustGamma adjust_gamma = 39; } }
And enum JitterMode { DEFAULT = 0; EXPAND = 1; SHRINK = 2; EXPAND_SYMMETRIC = 4; SHRINK_SYMMETRIC = 5; EXPAND_SYMMETRIC_XY = 6; SHRINK_SYMMETRIC_XY = 7; } // The mode of jittering // EXPAND - Only expands boxes // SHRINK - Only shrinks boxes // EXPAND_SYMMETRIC - Expands the boxes symmetrically along height and width // dimensions without changing the box center. The ratios of expansion along // X, Y dimensions are independent. // SHRINK_SYMMETRIC - Shrinks the boxes symmetrically along height and width // dimensions without changing the box center. The ratios of shrinking along // X, Y dimensions are independent. // EXPAND_SYMMETRIC_XY - Expands the boxes symetrically along height and // width dimensions and the ratio of expansion is same for both. // SHRINK_SYMMETRIC_XY - Shrinks the boxes symetrically along height and // width dimensions and the ratio of shrinking is same for both. // DEFAULT - Jitters each box boundary independently. optional JitterMode jitter_mode = 2 [default = DEFAULT]; }

@google-ml-butler google-ml-butler bot removed the stat:awaiting response Waiting on input from the contributor label Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models:research models that come under research directory type:bug Bug in the code
Projects
None yet
Development

No branches or pull requests

2 participants