experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 785 forks source link

Cast as int #341

Open zswitten opened 6 years ago

zswitten commented 6 years ago

Calling python gen_anchors.py -c config.json --anchors=3 errors out as below:

Traceback (most recent call last):
  File "gen_anchors.py", line 138, in <module>
    main(args)
  File "gen_anchors.py", line 130, in main
    centroids = run_kmeans(annotation_dims, num_anchors)
  File "gen_anchors.py", line 72, in run_kmeans
    old_distances = np.zeros((ann_num, anchor_num))
TypeError: 'str' object cannot be interpreted as an integer

This is because argparse casts command line inputs as strings. This PR fixes the problem by casting them as an int within the main method.

jbrambleDC commented 6 years ago

LGTM

robertlugg commented 5 years ago

You might also consider changing the argparser line instead:

argparser.add_argument(
'-a',
'--anchors',
*** type=int ***,
default=5,
help='number of anchors to use')