qqwweee / keras-yolo3

A Keras implementation of YOLOv3 (Tensorflow backend)
MIT License
7.14k stars 3.44k forks source link

yolo_video.py problem #601

Open zezisme opened 4 years ago

zezisme commented 4 years ago

after i trained my data,i can get the h5 file .but the file's size is less than the weight.h5,that the author hald given.therefore,when i run the yolo_video.py,there is some error:

Traceback (most recent call last): File "yolo_video.py", line 75, in detect_video(YOLO(*vars(FLAGS)), FLAGS.input, FLAGS.output) File "D:\zhouenze\keras-yolo3-master\yolo.py", line 46, in init self.boxes, self.scores, self.classes = self.generate() File "D:\zhouenze\keras-yolo3-master\yolo.py", line 75, in generate self.yolo_model.load_weights(self.model_path) # make sure model, anchors and classes match File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\saving.py", line 492, in load_wrapper return load_function(args, **kwargs) File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\network.py", line 1230, in load_weights f, self.layers, reshape=reshape) File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\saving.py", line 1237, in load_weights_from_hdf5_group K.batch_set_value(weight_value_tuples) File "C:\ProgramData\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2960, in batch_set_value tf_keras_backend.batch_set_value(tuples) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\backend.py", line 3066, in batch_set_value assign_op = x.assign(assign_placeholder) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py", line 1141, in assign self._shape.assert_is_compatible_with(value_tensor.shape) File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 1103, in assert_is_compatible_with raise ValueError("Shapes %s and %s are incompatible" % (self, other)) ValueError: Shapes (1, 1, 512, 255) and (75, 512, 1, 1) are incompatible

can anybody help me?thanks for a lot

tabmoo commented 4 years ago

Arguments are not passed to the script as far as I know (it's a bug). You need to manually edit the following in yolo.py:

class YOLO(object):
    _defaults = {
        "model_path": 'trained_weights_final888.h5',
        "anchors_path": 'f16_anchors.txt',
        "classes_path": 'classes.txt',

Enter the paths to your model, anchors, and classes and save yolo.py. Then try python yolo_video.py --image

Is it working (asking you to enter an image path)?

zezisme commented 4 years ago

Arguments are not passed to the script as far as I know (it's a bug). You need to manually edit the following in yolo.py: class YOLO(object): _defaults = { "model_path": 'trained_weights_final888.h5', "anchors_path": 'f16_anchors.txt', "classes_path": 'classes.txt',

Enter the paths to your model, anchors, and classes and save yolo.py. Then try python yolo_video.py --image Is it working (asking you to enter an image path)?

thanks for your advice,after i saw a reply in other issue,i found that i forget to change "classes_path"to 'model_data/voc_classes.txt',the original classes_path is coco_classes.txt;i'm so careless,now,it works.thank you!!(obviously,the weight.h5 file which author given is trained from coco datas)