0
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)    
Sven Eberth
  • 3,057
  • 12
  • 24
  • 29

2 Answers2

1

type below code on your cmd and make sure you are under the right folder which contain the weights.npz file(this could be CPUweights.npz check this file name after you do the train.py).And set the detected picture name as in.jpg also under the same folder

python detect.py in.jpg CPUweights.npz out.jpg
Mike Han
  • 11
  • 1
1

you can check the Updated Readme to find the solution.

./detect.py in.jpg weights.npz out.jpg
Sven Eberth
  • 3,057
  • 12
  • 24
  • 29
Tamil Selvan S
  • 562
  • 8
  • 25