微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在实现对象识别时解决“ValueError:Subshape must have connected start >= end because stride is negative”?

如何解决如何在实现对象识别时解决“ValueError:Subshape must have connected start >= end because stride is negative”?

我尝试实现以下代码

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(从开始 0 和结束 9223372036854775807 计算,超过了 rank 2 和 stride-1 的形状)。

我尝试将 tensorflow v2.5.0 降级到 v2.4.0,因为我在某处读到它可能有帮助,但没有。 谁能给点建议?

解决方法

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。