rizkiarm / LipNet

Keras implementation of 'LipNet: End-to-End Sentence-level Lipreading'
MIT License
635 stars 226 forks source link

ValueError: When using a generator for validation data, you must specify a value for `validation_steps`. #10

Closed rad182 closed 7 years ago

rad182 commented 7 years ago

Hi, Thanks for this open sourcing this lipnet. I'm still new to ML and still learning. However I'm trying to train 10 videos (from grid) for now(just for testing) using the "unseen_speakers" and getting an error about validation steps. Also enabled vtype='face', face_predictor_path=FACE_PREDICTOR_PATH

Below is the complete log

Using all available GPUs.
Using TensorFlow backend.

Enumerating dataset list from disk...
Found 10 videos for training.
Found 10 videos for validation.

_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
the_input (InputLayer)       (None, 75, 100, 50, 3)    0
_________________________________________________________________
zero1 (ZeroPadding3D)        (None, 77, 104, 54, 3)    0
_________________________________________________________________
conv1 (Conv3D)               (None, 75, 50, 25, 32)    7232
_________________________________________________________________
batc1 (BatchNormalization)   (None, 75, 50, 25, 32)    128
_________________________________________________________________
actv1 (Activation)           (None, 75, 50, 25, 32)    0
_________________________________________________________________
spatial_dropout3d_1 (Spatial (None, 75, 50, 25, 32)    0
_________________________________________________________________
max1 (MaxPooling3D)          (None, 75, 25, 12, 32)    0
_________________________________________________________________
zero2 (ZeroPadding3D)        (None, 77, 29, 16, 32)    0
_________________________________________________________________
conv2 (Conv3D)               (None, 75, 25, 12, 64)    153664
_________________________________________________________________
batc2 (BatchNormalization)   (None, 75, 25, 12, 64)    256
_________________________________________________________________
actv2 (Activation)           (None, 75, 25, 12, 64)    0
_________________________________________________________________
spatial_dropout3d_2 (Spatial (None, 75, 25, 12, 64)    0
_________________________________________________________________
max2 (MaxPooling3D)          (None, 75, 12, 6, 64)     0
_________________________________________________________________
zero3 (ZeroPadding3D)        (None, 77, 14, 8, 64)     0
_________________________________________________________________
conv3 (Conv3D)               (None, 75, 12, 6, 96)     165984
_________________________________________________________________
batc3 (BatchNormalization)   (None, 75, 12, 6, 96)     384
_________________________________________________________________
actv3 (Activation)           (None, 75, 12, 6, 96)     0
_________________________________________________________________
spatial_dropout3d_3 (Spatial (None, 75, 12, 6, 96)     0
_________________________________________________________________
max3 (MaxPooling3D)          (None, 75, 6, 3, 96)      0
_________________________________________________________________
time_distributed_1 (TimeDist (None, 75, 1728)          0
_________________________________________________________________
bidirectional_1 (Bidirection (None, 75, 512)           3048960
_________________________________________________________________
bidirectional_2 (Bidirection (None, 75, 512)           1181184
_________________________________________________________________
dense1 (Dense)               (None, 75, 28)            14364
_________________________________________________________________
softmax (Activation)         (None, 75, 28)            0
=================================================================
Total params: 4,572,156.0
Trainable params: 4,571,772.0
Non-trainable params: 384.0
_________________________________________________________________
Traceback (most recent call last):
  File "/Users/rad182/Documents/rizkiarm-LipNet/training/unseen_speakers/train.py", line 78, in <module>
    train(run_name, 0, 5000, 3, 100, 50, 75, 32, 50)
  File "/Users/rad182/Documents/rizkiarm-LipNet/training/unseen_speakers/train.py", line 74, in train
    pickle_safe=True)
  File "/usr/local/lib/python2.7/site-packages/keras/legacy/interfaces.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/keras/engine/training.py", line 1783, in fit_generator
    raise ValueError('When using a generator for validation data, '
ValueError: When using a generator for validation data, you must specify a value for `validation_steps`.
michiyosony commented 7 years ago

Hi @rad182, I'm also trying to do a simple example training using unseen_speakers. It sounds like I'm taking the same steps as you, though I'm using 17 training videos and 17 validation videos. I also encountered this error and will post here if I figure anything out.

I see you changed the title of the issue. Does that mean you figured out the problem? If so, could you post how you resolved it?

rad182 commented 7 years ago

@michiyosony i just changed the minibatch_size param in train() to the number of videos to train and it should work but I'm getting a new error which is updated above.

michiyosony commented 7 years ago

@rad182 I just saw that, thanks! For the benefit of future users, I think it would be good to revert this above description and open a new issue with the new stack track.

deepakgupta1313 commented 6 years ago

Please tell me if the the following is the correct way of making changes in train.py, to include vface and face_predictor_path ? lip_gen = BasicGenerator(dataset_path=DATASET_DIR, vtype = "face", face_predictor_path="/home/deepakgupta1313/Desktop/Deepak/Programs/Github/LipNet/common/predictors/shape_predictor_68_face_landmarks.dat", minibatch_size=minibatch_size, img_c=img_c, img_w=img_w, img_h=img_h, frames_n=frames_n,

shensheng27 commented 6 years ago

FYI if the validation_steps == 0 will raise this ValueError

engahmed1190 commented 6 years ago

I have edited fit_generator and assign a value to validation_step, is this the correct way to so it @rizkiarm @shensheng27

    lipnet.model.fit_generator(generator=lip_gen.next_train(),
                        steps_per_epoch=lip_gen.default_training_steps, epochs=stop_epoch,
                        validation_data=lip_gen.next_val(), validation_steps=1,
                        callbacks=[checkpoint, statistics, visualize, lip_gen, tensorboard, csv_logger],
                        initial_epoch=start_epoch,
                        verbose=1,
                        max_q_size=5,
                        workers=2,
                        pickle_safe=True)