Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Frame count is not OK for video #36

Open
orenpapers opened this issue Oct 20, 2020 · 2 comments
Open

Error: Frame count is not OK for video #36

orenpapers opened this issue Oct 20, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@orenpapers
Copy link

orenpapers commented Oct 20, 2020

I have the following code that is based on the example:
And I get the error:

Epoch 1/3
21/69 [========>.....................] - ETA: 54:24 - loss: 1.5353Frame count is not OK for video /content/drive/My Drive/videos/dataset/A/video7.avi, 2 total, 1 extracted

while fitting.
Any idea why?
Thanks!

sequence_lengths = None

numberOfVideos = 10
videoLength = 5
numberOfPrediction = 5


def defModel():

  frames, channels, rows, columns = 5,3,224,224

  video = Input(shape=(frames,
                    rows,
                    columns,
                    channels))

  cnn_base = VGG16(
                # input_shape=(rows,columns,channels),
                weights="imagenet",
                include_top=True)
  cnn_base.trainable = False

  cnn = Model(cnn_base.input, cnn_base.layers[-3].output, name="VGG_fm")

  encoded_frames = TimeDistributed(cnn , name = "encoded_frames")(video)
  encoded_sequence = LSTM(4, name = "encoded_seqeunce")(encoded_frames)
  hidden_layer = Dense(4, activation="relu" , name = "hidden_layer")(encoded_sequence)
  outputs = Dense(numberOfPrediction, activation="softmax")(hidden_layer)

  model = Model([video], outputs)  
  model.compile(loss='categorical_crossentropy', optimizer='adam')
  model.summary()

  return model

model = defModel()

import os
import glob
from keras_video import VideoFrameGenerator

classes = ["A","B","C","D","E"]
classes.sort()
 SIZE = (224, 224)
CHANNELS = 3
 
# pattern to get videos and classes
glob_pattern='/content/drive/videos/dataset/{classname}/*.avi'

data_aug = tensorflow.keras.preprocessing.image.ImageDataGenerator(
    zoom_range=.1,
    horizontal_flip=True,
    rotation_range=8,
    width_shift_range=.2,
    height_shift_range=.2)

train = VideoFrameGenerator(
    classes=classes, 
    glob_pattern=glob_pattern,
    split_val=.33, 
    shuffle=True,
    target_shape=SIZE,
    nb_channel=CHANNELS,
    transformation=data_aug,
    use_frame_cache=True)

valid = train.get_validation_generator()

EPOCHS=3
 
callbacks = [
    keras.callbacks.ReduceLROnPlateau(verbose=1),
    keras.callbacks.ModelCheckpoint(
        'chkp/weights.{epoch:02d}-{val_loss:.2f}.hdf5',
        verbose=1),
]
model.fit_generator(
    train,
    validation_data=valid,
    verbose=1,
    epochs=EPOCHS,
    # callbacks=callbacks
)

@LS4203
Copy link

LS4203 commented Nov 9, 2020

This basically means the video does not contain those amount of frames. Navigate to that specific video file and you will find it out it does not have those frames. Usually, the video is either short or corrupt. Highly, likely corrupt!
Just delete that video and the error will go away.

@metal3d
Copy link
Owner

metal3d commented Jan 25, 2021

That's a problem I want to resolve

@metal3d metal3d added the bug Something isn't working label Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants