1

我试图实现以下代码:

from imageai.Detection import ObjectDetection
detector = ObjectDetection()
model_path = "yolo-tiny.h5"
input_path = "passport_photo.png"
output_path = "new.jpg"
detector.setModelTypeAsTinyYOLOv3()
detector.setModelPath(model_path)
detector.loadModel()
detection = detector.detectObjectsFromImage(input_image=input_path, output_image_path=output_path)
for eachItem in detection:
    print(eachItem["name"] , " : ", eachItem["percentage_probability"])

但出现以下错误:

ValueError: Subshape 必须计算 start >= end,因为 stride 为负,但为 0 和 2(从 start 0 和 end 9223372036854775807 计算,超过 rank 2 和 stride-1 的形状)。

我尝试将 tensorflow v2.5.0 降级到 v2.4.0,因为我在某处读到它可能会有所帮助,但它没有。任何人都可以提出一些建议吗?

4

1 回答 1

1

这似乎是因为 TensorFlow 2 对模型数据的类型做出了新的假设。我遇到了您遇到的确切问题并按照此评论所说的做了,并且它修复了它,所以我至少可以继续前进。

于 2021-08-10T20:05:35.897 回答