Skip to content

PyTorch implementation of Phase Based Motion Magnification

License

Notifications You must be signed in to change notification settings

itberrios/phase_based

Repository files navigation

phase_based

PyTorch implementation of Phase Based Motion Magnification. It is based off of MATLAB source that can be found here, the input videos can also be found at this location. The PyTorch implementation allows for easily parallization on a GPU and is even much faster than a numpy implementation even without a GPU.

The main notebook contains a detailed hands-on overview of the Motion Magnification Algorithm. The image below shows an example of how the motion is amplified across all the video frames. image


While the notebook is good for interactive use, the main script called motion_magnification.py is a better option to run on your own videos. It can be called from the commandline or alternatively the arguments can be input directly in the script.

Applying Motion Magnification

The following commandline arguments produce the following GIF:
python motion_magnification.py -v videos/crane_crop.avi -a 25 -lo 0.2 -hi 0.25 -n luma3 -p half_octave -s 5.0 -b 4 -c 0.7 -gif True

crane_crop_luma3_25x

Arguments:

A list of the arguments is provided below. Please use the help option to find more info: python motion_magnification.py --help

  • --video_path, -v Path to input video (Required)
  • --phase_mag, -a Phase Magnification Factor (Required)
  • --freq_lo, -lo Low Frequency cutoff for Temporal Filter (Required)
  • --freq_hi, -hi High Frequency cutoff for Temporal Filter (Required)
  • --colorspace, -n Colorspace for processing
  • --pyramid_type, -p Complex Steerable Pyramid Type
  • --sigma, -s Gaussian Kernel for Phase Filtering
  • --attenuate, -a Attenuates Other frequencies outside of lo and hi
  • --sample_frequency, -fs Overrides video sample frequency
  • --reference_index, -r Index of DC reference frame
  • --scale_factor, -c Factor to scale frames for processing
  • --batch_size, -b CUDA batch size
  • --save_directory, -d Directory for output files (default is input video directory)
  • --save_gif, -gif Saves results as a GIF

About

PyTorch implementation of Phase Based Motion Magnification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published