首页 > 解决方案 > AttributeError:模块“tensorflow._api.v2.image”没有属性“resize_images”

问题描述

我正在使用预训练模型来检测对象,因为我得到了错误 tensorflow version = 2.2.0 keras version = 2.3.1

下面是我的代码

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.0.1.h5"))
detector.loadModel()

custom_objects = detector.CustomObjects(person=True, car=False)
detections = detector.detectCustomObjectsFromImage(input_image=os.path.join(execution_path ,"image.jpg"),output_image_path=os.path.join(execution_path , "image_new.jpg"), custom_objects=custom_objects, minimum_percentage_probability=65)

for eachObject in detections:
    print(eachObject["name"] + " : " + eachObject["percentage_probability"] )
    print("--------------------------------")

标签: tensorflowkerasdeep-learningresnet

解决方案


推荐阅读