Object Detection API, TensorFlow and Keras compatibility issue

80 Views Asked by At

I'm trying to follow this tutorial and I'm running into issue setting up the environment.

https://towardsdatascience.com/borderless-tables-detection-with-deep-learning-and-opencv-ebf568580fe2

The tutorial requires Python 3.7, TensorFlow 2.3 and https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI

After executing the following commands:

protoc object_detection\protos*.proto — python_out=. copy

object_detection\packages\tf2\setup.py .

python setup.py install

it will install keras by itself then when I execute the following command: python object_detection\builders\model_builder_tf2_test.py

I'll get the following error:

Traceback (most recent call last):
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\models\keras_models\resnet_v1.py", line 28, in
from keras.applications import resnet # pylint: disable=g-import-not-at-top
ModuleNotFoundError: No module named 'keras'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "object_detection\builders\model_builder_tf2_test.py", line 24, in from object_detection.builders import model_builder
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\model_builder.py", line 37, in
from object_detection.meta_architectures import deepmac_meta_arch
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\meta_architectures\deepmac_meta_arch.py", line 20, in
from object_detection.models.keras_models import resnet_v1
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\models\keras_models\resnet_v1.py", line 30, in
from tf_keras.applications import resnet # pylint: disable=g-import-not-at-top
ModuleNotFoundError: No module named 'tf_keras'

I'm not good at debugging other people's work but I tried deleting the standalone keras version and sticking with tensorflow's integrated keras. Then I went into resnet_v1.py and changed

try:
  from keras.applications import resnet  # pylint: disable=g-import-not-at-top
except ImportError:
  from tf_keras.applications import resnet  # pylint: disable=g-import-not-at-top

to

try:
  from tensorflow.keras.applications import resnet  # pylint: disable=g-import-not-at-top
except ImportError:
  from tf_keras.applications import resnet  # pylint: disable=g-import-not-at-top

Now I'm getting the following error:

(borderlessTable) C:\Users\user\Desktop\Symfony\models\research>python object_detection\builders\model_builder_tf2_test.py
2024-01-14 18:05:20.530858: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2024-01-14 18:05:20.531083: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
File "object_detection\builders\model_builder_tf2_test.py", line 24, in from object_detection.builders import model_builder
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\model_builder.py", line 37, in
from object_detection.meta_architectures import deepmac_meta_arch
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\meta_architectures\deepmac_meta_arch.py", line 28, in
import tensorflow_io as tfio # pylint:disable=g-import-not-at-top
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\tensorflow_io-0.31.0-py3.7-win-amd64.egg\tensorflow_io_init_.py", line 17, in
from tensorflow_io.python.api import * # pylint: disable=wildcard-import
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\tensorflow_io-0.31.0-py3.7-win-amd64.egg\tensorflow_io\python\api_init_.py", line 19, in
from tensorflow_io.python.ops.io_dataset import IODataset
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\tensorflow_io-0.31.0-py3.7-win-amd64.egg\tensorflow_io\python\ops_init_.py", line 96, in
plugin_ops = load_library("libtensorflow_io_plugins.so", "fs")
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\tensorflow_io-0.31.0-py3.7-win-amd64.egg\tensorflow_io\python\ops_init
.py", line 64, in load_library
l = load_fn(f)
File "C:\Users\user.conda\envs\borderlessTable\lib\site-packages\tensorflow_io-0.31.0-py3.7-win-amd64.egg\tensorflow_io\python\ops_init
.py", line 56, in
load_fn = lambda f: tf.experimental.register_filesystem_plugin(f) is None AttributeError: module 'tensorflow._api.v2.experimental' has no attribute 'register_filesystem_plugin'

How to resolve this?

0

There are 0 best solutions below