Open M-Zubair10 opened 2 years ago
Hi, I got the same issue and finally solved it. Hope this may help you. I tried install imageai by "pip install imageai --upgrade". This gives me version 2.1.5, which is outdated. In this package, the import "from keras.layers.normalization import BatchNormalization" is not compatible for the new version keras. Next, I tried clone this package and put the "imageai" directory in the same folder with my python code. Then everything works fine. (I have tried to install version 2.1.6 by "pip install imageai==2.1.6", but there are lots of package to be resolved. So maybe clone this package is the best way to do what you want)
I am a newbie and don't have a knowledge of tensorflow, keras I found imageAI as a powerful tool for my simple image processing in python The problem is after i install all of the dependencies and imageAI, I keep getting error no module named BatchNormalization From further research i change a little bit code of mode according to stackoverflow guide i.e,
detect('Sample/img1.png')
File "C:\Users\HP\PycharmProjects\Selenium-master\CaptchaSolutions\Hcaptcha\bin\detection.py", line 11, in detect
detector.loadModel(detection_speed=speed)
File "C:\Users\HP\PycharmProjects\Selenium-master\venv\lib\site-packages\imageai\Detection__init__.py", line 190, in loadModel
model = resnet50_retinanet(num_classes=80)
File "C:\Users\HP\PycharmProjects\Selenium-master\venv\lib\site-packages\imageai\Detection\keras_retinanet\models\resnet.py", line 86, in resnet50_retinanet
return resnet_retinanet(num_classes=num_classes, backbone='resnet50', inputs=inputs, *kwargs)
File "C:\Users\HP\PycharmProjects\Selenium-master\venv\lib\site-packages\imageai\Detection\keras_retinanet\models\resnet.py", line 69, in resnet_retinanet
resnet = keras_resnet.models.ResNet50(inputs, include_top=False, freeze_bn=True)
File "C:\Users\HP\PycharmProjects\Selenium-master\venv\lib\site-packages\imageai\Detection\keras_resnet\models_2d.py", line 190, in ResNet50
return ResNet(inputs, blocks, numerical_names=numerical_names, block=keras_resnet.blocks.bottleneck_2d, include_top=include_top, classes=classes, args, **kwargs)
File "C:\Users\HP\PycharmProjects\Selenium-master\venv\lib\site-packages\imageai\Detection\keras_resnet\models_2d.py", line 68, in ResNet
x = keras_resnet.layers.BatchNormalization(axis=axis, epsilon=1e-5, freeze=freeze_bn, name="bn_conv1")(x)
File "C:\Users\HP\PycharmProjects\Selenium-master\venv\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\HP\PycharmProjects\Selenium-master\venv\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 692, in wrapper
raise e.ag_error_metadata.to_exception(e)
TypeError: Exception encountered when calling layer "bn_conv1" (type BatchNormalization).
from keras.layers.normalization.batch_normalization import BatchNormalization
Now keep getting this error, don't know what to do C:\Users\HP\PycharmProjects\Selenium-master\venv\Scripts\python.exe C:/Users/HP/PycharmProjects/Selenium-master/CaptchaSolutions/Hcaptcha/bin/detection.py 2022-03-24 20:37:30.803138: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2022-03-24 20:37:30.803374: 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. 2022-03-24 20:37:34.824834: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found 2022-03-24 20:37:34.825037: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303) 2022-03-24 20:37:34.827954: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: MuhammadZubair 2022-03-24 20:37:34.828200: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: MuhammadZubair 2022-03-24 20:37:34.828693: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. Traceback (most recent call last): File "C:\Users\HP\PycharmProjects\Selenium-master\CaptchaSolutions\Hcaptcha\bin\detection.py", line 22, inin user code:
Call arguments received: • args=('tf.Tensor(shape=(None, None, None, 64), dtype=float32)',) • kwargs={'training': 'None'}
Process finished with exit code 1
Any help would be appreciated