Skip to main content

PyPI version Build Status

Keras Sequence Video generators

This package proposes some classes to work with Keras (included in TensorFlow) that generates batches of frames from video files.

It is useful to work with Time Distributed Layer with Video input (frames). Then you may use GRU or LSTM. See articles:

An provided example of usage can be displayed in nbviewer here.

Requirements are:

  • Python >= 3.6 (Python 2 will never been supported)
  • OpenCV
  • numpy
  • Keras >= 2
  • TensorFlow >= 1.15 (or other backend, not tested, TensorFlow is needed by Keras)

TensorFlow 2 works as well. This requirements is not integrated in the setup.py to let you choose the version, or to let you try with other backend. We mean that you will need to install a backend yourself (e.g. pip install tensorflow)

If you want to compile the package, you need:

  • sphinx to compile doc (work in progress)
  • setuptools

Installation

You can install the package via pip:

pip install keras-video-generators

If you want to build from sources, clone the repository then:

python setup.py build

Usage

The package contains 3 generators that inherits Sequence interface. So they may be used with model.fit_generator():

  • VideoFrameGenerator that will take the choosen number of frames from the entire video
  • SlidingFrameGenerator that takes frames with decay for the entire video or with a sequence time
  • OpticalFlowGenerator that gives optical flow sequence from frames with different methods (experimental)

Each of these generators accepts parameters:

  • glob_pattern that must contain {classname}, e.g. './videos/{classname}/*.avi' - the "classname" in string is used to detect classes
  • nb_frames that is the number of frame in the sequence
  • batch_size that is the number of sequence in one batch
  • transformation that can be None or or ImageDataGenerator to make data augmentation
  • use_frame_cache to use with caution, if set to True, the class will keep frames in memory (without augmentation). You need a lot of memory
  • and many more, see class documentation

Changelog

v1.0.14

  • Changes to get first and last frames in sequence

v1.0.13

  • try to fix SageMaker problem by avoiding usage of internal keras from tensorflow

v1.0.12

  • fix transformation error with SlidingFrameGenerator

v1.0.11

  • set generator to be Iterable
  • frame cache was disabled by error, it's back now
  • fixup import Sequence from tensorflow.keras
  • fix frame count problems for video with bad headers

v1.0.10

  • fix Windows problems with path using backslashes
  • add auto discovery for classes if "None" is sent
  • add travis tests

v1.0.9

  • fix frame counter in SlidingFrameGenerator

v1.0.8

  • fix tiny video frame count
  • refactorisation
  • pep8
  • fix problems for video without headers

v1.0.7

  • fix name check in classes to get them from filename
  • add split_test and split_val

v1.0.5

  • fix package generation

v1.0.4

  • fix assertion

Metadata

Release files for keras-video-generators 1.0.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for keras-video-generators 1.0.14
File Size Uploaded
keras-video-generators-1.0.14.tar.gz 11.6 kB Details

Release files / keras-video-generators-1.0.14.tar.gz

Download URL keras-video-generators-1.0.14.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5f15cac7a5f807f5dd9bafce6309f66ef3118110352caa04f8a4674b39a5091d
BLAKE2b-256 checksum
How to use checksums
d998ff550be6084b0537f1340783a6850a2f2b62b87273472a56c17ed84bcdb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

1.0.14 This release

1 release file

1.0.13

1 release file

1.0.12

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page