tensorflow 代码python中的深层anpr错误?github.com/matthewearl/deep-anpr

bf1o4zei  于 2023-01-31  发布在  Python
关注(0)|答案(2)|浏览(118)
if __name__ == "__main__":
    im = cv2.imread(sys.argv[1])
    im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) / 255.

    f = numpy.load(sys.argv[2])
    param_vals = [f[n] for n in sorted(f.files, key=lambda s: int(s[4:]))]

    for pt1, pt2, present_prob, letter_probs in post_process(
                                                  detect(im_gray, param_vals)):
        pt1 = tuple(reversed(map(int, pt1)))
        pt2 = tuple(reversed(map(int, pt2)))

        code = letter_probs_to_code(letter_probs)

        color = (0.0, 255.0, 0.0)
        cv2.rectangle(im, pt1, pt2, color)

        cv2.putText(im,
                    code,
                    pt1,
                    cv2.FONT_HERSHEY_PLAIN, 
                    1.5,
                    (0, 0, 0),
                    thickness=5)

        cv2.putText(im,
                    code,
                    pt1,
                    cv2.FONT_HERSHEY_PLAIN, 
                    1.5,
                    (255, 255, 255),
                    thickness=2)

    cv2.imwrite(sys.argv[3], im)

error  im = cv2.imread(sys.argv[1])
IndexError: list index out of range)
thtygnil

thtygnil1#

在您的cmd上键入以下代码,并确保您位于包含weights.npz文件的正确文件夹下(这可能是CPUweights.npz,请在完成www.example.com后检查此文件名train.py)。并将检测到的图片名称设置为in.jpg,也位于同一文件夹下

python detect.py in.jpg CPUweights.npz out.jpg
cbeh67ev

cbeh67ev2#

您可以查看更新的自述文件以查找解决方案。

./detect.py in.jpg weights.npz out.jpg

相关问题