allanzelener / YAD2K

YAD2K: Yet Another Darknet 2 Keras
Other
2.72k stars 880 forks source link

unused weight issue #59

Open Pankajchandan opened 7 years ago

Pankajchandan commented 7 years ago

I trained a dataset on darknet and imported weight and config files to yad2k . while converting
to keras model i get this error:

Saved Keras model to model_data/yolo.h5 Read 67132484 of 67132485.0 from Darknet weights. Traceback (most recent call last): File "yad2k.py", line 271, in _main(parser.parse_args()) File "yad2k.py", line 263, in _main print('Warning: {} unused weights'.format(len(remaining_weights))) TypeError: object of type 'float' has no len()

although the h5 file gets saved but nothing gets predicted when i test it on images.

Firyuza commented 7 years ago

Check to see if all weights have been read.

remaining_weights = len(weights_file.read()) / 4
weights_file.close()
print('Read {} of {} from Darknet weights.'.format(count, count + remaining_weights))
**if remaining_weights > 0:
    print('Warning: {} unused weights'.format(remaining_weights))**

Maybe try to debug yad2k.py. what is the type of variable remaining_weights. Or just comment out _print('Warning: {} unused weights'.format(remainingweights))

maslovw commented 7 years ago

I have the same issue on tiny_yolo coco weights

Saved Keras model to tiny-yolo/tiny-yolo2.h5
Read 11237145 of 11237146.0 from Darknet weights.
Warning: 1.0 unused weights
skbacker commented 7 years ago

@maslovw

The tiny-yolo.cfg file was recently updated but yad2k.py was not. (Https://github.com/pjreddie/darknet/commit/b34082019d6d262dd9bce4c4ee4b0bd038a1560a)

Instead, Look at the above diff file and revert the cfg and try using the weights file below. https://github.com/thomaspark-pkj/pyyolo/blob/master/tiny-yolo.weights

I did not have a problem :-)


Good news! How to patch yad2k.py => see https://github.com/allanzelener/YAD2K/issues/65#issuecomment-325184900