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

No module named 'tf_keras.legacy_tf_layers' #41

Closed
RK-GOML opened this issue Feb 19, 2024 · 1 comment
Closed

No module named 'tf_keras.legacy_tf_layers' #41

RK-GOML opened this issue Feb 19, 2024 · 1 comment

Comments

@RK-GOML
Copy link

RK-GOML commented Feb 19, 2024

I have updated the code to work with tensorflow2.x & using tf_slim.

When you call the Run module for inferencing facing below error:
File "\app\body_measurements.py", line 336, in main
model = RunModel(sess=sess)
^^^^^^^^^^^^^^^^^^^
File "\app\body_measurements.py", line 98, in init
self.build_test_model_ief()
File "\app\body_measurements.py", line 116, in build_test_model_ief
self.img_feat, self.E_var = img_enc_fn(self.images_pl,
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\libs\Body_measurements\src\models.py", line 47, in Encoder_resnet
net, end_points = resnet_v2.resnet_v2_50(
^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tf_slim\nets\resnet_v2.py", line 282, in resnet_v2_50
return resnet_v2(
^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tf_slim\nets\resnet_v2.py", line 220, in resnet_v2
net = resnet_utils.stack_blocks_dense(net, blocks, output_stride)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "venv_py311\Lib\site-packages\tf_slim\ops\arg_scope.py", line 184, in func_with_args
return func(*args, **current_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tf_slim\nets\resnet_utils.py", line 219, in stack_blocks_dense
net = block.unit_fn(net, rate=1, **unit)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tf_slim\ops\arg_scope.py", line 184, in func_with_args
return func(*args, **current_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tf_slim\nets\resnet_v2.py", line 104, in bottleneck
preact = layers.batch_norm(
^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tf_slim\ops\arg_scope.py", line 184, in func_with_args
return func(*args, **current_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tf_slim\layers\layers.py", line 663, in batch_norm
layer = normalization_layers.BatchNormalization(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tensorflow\python\layers\normalization.py", line 30, in getattr
return normalization.BatchNormalization
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tensorflow\python\util\lazy_loader.py", line 67, in getattr
module = self._load()
^^^^^^^^^^^^
File "\venv_py311\Lib\site-packages\tensorflow\python\util\lazy_loader.py", line 50, in load
module = importlib.import_module(self.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "\venv_py311\Lib\importlib_init
.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1126, in _find_and_load_unlocked
File "", line 241, in _call_with_frames_removed
File "", line 1204, in _gcd_import
File "", line 1176, in _find_and_load
File "", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tf_keras.legacy_tf_layers'

@RK-GOML
Copy link
Author

RK-GOML commented Feb 19, 2024

Solution to the own problem:

It's tf_slim issue:
google-research/tf-slim#24

@RK-GOML RK-GOML closed this as completed Feb 19, 2024
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

1 participant