Coder Social home page Coder Social logo

okankop / vidaug Goto Github PK

View Code? Open in Web Editor NEW
371.0 9.0 75.0 44.39 MB

Effective Video Augmentation Techniques for Training Convolutional Neural Networks

License: MIT License

Python 100.00%
augmentation deep-learning deep-neural-networks video-augmentation convolutional-neural-networks

vidaug's Introduction

Video Augmentation Techniques for Deep Learning

This python library helps you with augmenting videos for your deep learning architectures. It converts input videos into a new, much larger set of slightly altered videos.

Original Video

Requirements and installation

Required packages:

  • numpy
  • PIL
  • scipy
  • skimage
  • OpenCV (i.e. cv2)

For installation, simply use sudo pip install git+https://github.com/okankop/vidaug. Alternatively, the repository can be download via git clone https://github.com/okankop/vidaug and installed by using python setup.py sdist && pip install dist/vidaug-0.1.tar.gz.

Examples

A classical video classification with CNN using augmentations on videos. Train on batches of images and augment each batch via random crop, random crop and horizontal flip:

from vidaug import augmentors as va

sometimes = lambda aug: va.Sometimes(0.5, aug) # Used to apply augmentor with 50% probability
seq = va.Sequential([
    va.RandomCrop(size=(240, 180)), # randomly crop video with a size of (240 x 180)
    va.RandomRotate(degrees=10), # randomly rotates the video with a degree randomly choosen from [-10, 10]  
    sometimes(va.HorizontalFlip()) # horizontally flip the video with 50% probability
])

for batch_idx in range(1000):
    # 'video' should be either a list of images from type of numpy array or PIL images
    video = load_batch(batch_idx)
    video_aug = seq(video)
    train_on_video(video)

The videos below show examples for most augmentation techniques:

Augmentation Type Augmented Video
Piecewise Affine Transform Piecewise Affine Transform
Superpixel Superpixel
Gausian Blur Gausian Blur
Invert Color Invert Color
Rondom Rotate Rondom Rotate
Random Resize Random Resize
Translate Translate
Center Crop Center Crop
Horizontal Flip Horizontal Flip
Vertical Flip Vertical Flip
Add Add
Multiply Multiply
Downsample Downsample
Upsample Upsample
Elastic Transformation Elastic Transformation
Salt Salt
Pepper Cropping
Shear Shear

vidaug's People

Contributors

ahmetgunduz avatar devksingh4 avatar okankop avatar panahiparham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vidaug's Issues

Is it for one video (sequence of images) or a batch of videos?

Thank you for providing your code.
While checking the example code

for batch_idx in range(1000):
    # 'video' should be either a list of images from type of numpy array or PIL images
    video = load_batch(batch_idx)
    video_aug = seq(video)
    train_on_video(video)

the loop is running on batch_idx (i suppose batch of videos) but in comment it says video is list of images. Can I give a batch of videos or I will have to give single video at a time?

How to input the videos

Hi,
Thanks for the code. Just wanted to know how to pass multiple images to the code for Video Augmentation.

Thanks,
Mritula

Sequence exists with only message "Killed"

Hi,
I am applying the pepper or salt augmenters but the process keeps getting killed and I am not sure why. Only message is "Killed". I tried to look for where this might be coming from but could not identify the source.

camera vibration augmentation

Hello
How are you?
Thanks for contributing to this project.
I have a question.
Does this library contain a camera motion augmentation?
Here the camera motion means a camera's vibration(shaking).

00000
00001
00002
00003
00004
00005
00006

Please check the above sequence frames which are shaking by camera vibration.
Could u implement this augmentation in your repo?
Thanks

RandomResize does not work with ndarray

\lib\site-packages\vidaug\augmentors\affine.py in __call__(self, clip)
     90         new_size = (new_h, new_w)
     91         if isinstance(clip[0], np.ndarray):
---> 92             return [scipy.misc.imresize(img, size=(new_h, new_w),interp=self.interpolation) for img in clip]
     93         elif isinstance(clip[0], PIL.Image.Image):
     94             return [img.resize(size=(new_w, new_h), resample=self._get_PIL_interp(self.interpolation)) for img in clip]

\site-packages\vidaug\augmentors\affine.py in <listcomp>(.0)
     90         new_size = (new_h, new_w)
     91         if isinstance(clip[0], np.ndarray):
---> 92             return [scipy.misc.imresize(img, size=(new_h, new_w),interp=self.interpolation) for img in clip]
     93         elif isinstance(clip[0], PIL.Image.Image):
     94             return [img.resize(size=(new_w, new_h), resample=self._get_PIL_interp(self.interpolation)) for img in clip]

AttributeError: module 'scipy.misc' has no attribute 'imresize'

When trying to use RandomResize it gives the above error. Seems to be caused by deprecated scipy API.

imresize is deprecated! imresize is deprecated in SciPy 1.0.0, and will be removed in 1.3.0. Use Pillow instead: numpy.array(Image.fromarray(arr).resize()).

How to run this application?

What I see from your ReadMe file is, you are training in batches.
I wanted to know, How to generate Augmented Videos as you shown in some output gifs??
Could you please mention clearly about it!!??

How about using ImageDataGenerator in Keras for videos?

Hello,
First, I would like to thank you for this tremendous contribution to video data augmentation. I am looking for a way to use video data augmentation while training models on video classification/labelling, I know that for images ImageDataGenerator from Keras exists as a data augmentor. However, it is not specifically targetted for videos.
However, I saw a kind of augmentation used in this website article for video classification. I don't know if you came across ImageDataGenerator, but I would like to know if it is possible to use ImageDataGenerator rather than your functions to apply data augmentation for videos ?

AttributeError: module 'numpy' has no attribute 'float'

Hi!

First of all: thanks for this awesome package!
But I'm receiving this numpy error:

AttributeError: module 'numpy' has no attribute 'float'.
`np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

The error occurs in augmentors/intesity.py#L162

On the SuperPixel Augmentation

I can not get the right effect for superpixel augmentation with the original video on the homepage. Would you please tell me what is the proper parameter configuration for the superpixel augmentation?

Naming error

I found that the directory name is augmentors, while in the document it's augmenters
Also, va.RandomRotate(angle=10) should be va.RandomRotate(degree=10)
Are these functions tested?

Document for the project

Hello okankop!

This is a really impressive repo and it definitely saved me from writing those data augmentation functions. Thanks greatly for the great work!

But I do think it will be even better if you can provide a document, however easy it is. Maybe just add something to explain the input parameters at the bottom of the form in README.md.

Thanks again!

'Sequential' object has no attribute 'augment_images'

hi,thank you for your code. When I use your example an error occurred ‘Sequential' object has no attribute 'augment_images’. Can you tell me how to slove it?

from vidaug import augmentors as va

sometimes = lambda aug: va.Sometimes(0.5, aug) # Used to apply augmentor with 50% probability
seq = va.Sequential([
va.RandomCrop(size=(240, 180)), # randomly crop video with a size of (240 x 180)
va.RandomRotate(degrees=10), # randomly rotates the video with a degree randomly choosen from [-10, 10]
sometimes(va.HorizontalFlip()) # horizontally flip the video with 50% probability
])

for batch_idx in range(1000):
# 'video' should be either a list of images from type of numpy array or PIL images
video = load_batch(batch_idx)
video_aug = seq.augment_images(video)
train_on_video(video)

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.