I tried to implement the following code:

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"])

but got the following error :

ValueError: Subshape must have computed start >= end since stride is negative, but is 0 and 2 (computed from start 0 and end 9223372036854775807 over shape with rank 2 and stride-1).

I tried downgrading tensorflow v2.5.0 and to v2.4.0 as I read somewhere that it might help, but it didn't. Can anyone suggest something?

1

There are 1 best solutions below

0
On

This seems to be because TensorFlow 2 makes new assumptions about the types of the model data. I had the exact problem you had and did what this comment says, and it fixed it so I could at least move on.