我遵循了一个关于物体检测的教程,它给了我这样的代码:
from imageai.Detection import ObjectDetection
import os
execution_path = os.getcwd()
detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.1.0.h5"))
detector.loadModel()
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg"))
for eachObject in detections:
print(eachObject["name"] , " : " , eachObject["percentage_probability"] )问题是,它总是给我这样一个错误:ImportError: cannot import name 'BatchNormalization' from 'keras.layers.normalization'
我到处寻找,我想这与我的tensorflow版本有关,但我从未找到一个有效的解决方案。
发布于 2021-11-26 14:01:50
您必须从tf.keras.layers导入批量规范化
import tensorflow as tf
from tf.keras.layers import BatchNormalization希望,这个Documentation可以帮助你更好。
如果我的答案发现你是well..upvote。
。快乐学习
发布于 2022-01-15 09:56:29
当您收到错误消息时,应该会为ini.py文件指定一个目录。用你的IDE打开它,然后通过这条线。不知何故,它对我起作用了。
from keras.layers.normalization.batch_normalization import BatchNormalizationhttps://stackoverflow.com/questions/70124870
复制相似问题