代码python中的深度anpr错误?https://github.com/matthewearl/deep-anpr

时间:2017-10-01 10:40:43

标签: python tensorflow anpr

if __name__ == "__main__":
    im = cv2.imread(sys.argv[1])
    im_gray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) /`enter code here` 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)    

在这里输入代码

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:1)

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

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