Skip to content
/ demos Public

Real time python demonstrations for machine learning, image and signal processing

Notifications You must be signed in to change notification settings

rflamary/demos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PYTHON Demos

This repository contains several python3 scripts demonstrations. They all have MIT license.

How to run

All scripts from the demos are available in the demos folder.

One can run easily all demos using the demo.py script in the root folder.

The list of available demos is given by:

python3 demo.py -l

To run the demo you can execute:

python3 demo.py [demo_name]

To print the list of dependencies for a given demo you can run:

python3 demo.py -d [demo_name]

you can store it in a text file and install it with pip.

Demos

Total Variation on webcam

In this demonstration we perform online Total Variation regularization on the video captured on the webcam.

Screenshot:

screenshot

Shortcuts:

  • q : Quit demo
  • s : Save screen to png
  • s : Save screen to png
  • Space : Do full image TV
  • h : Do half image TV (screenshot)
  • + : Make TV regularization stronger
  • - : Make TV regularization weaker
  • n : Add salt and pepper noise
  • b : Make noise more aggressive
  • , : Make noise less aggressive

Dependencies:

This demo uses opencv-python for webcam access and visualization and prox_tv for total variation proximal operator.

Real time audio spectrum

In this demonstration we plot in real time the audio spectrum (and the time frequency analysis) of the microphone.

screenshot

Shortcuts:

  • q or Esc : Quit demo
  • Space : Pause/unpause demo
  • r : Reset time
  • + or N : Multiply nfft by 2 (zoom in to lower frequencies)
  • - or n : Divide nfft by 2 (zoom out)
  • W : Multiply time window size by 2
  • w : Divide time window size by 2
  • P/p : Change scale of power spectrum (up/down)
  • S/s : Change scale of power spectrum (up/down)

Dependencies:

This demo uses pygame for visualization and PyAudio for microphone recording.

2D classification demo

In this demonstration we illustrate the decision function and update of 2D classifiers when adding training samples from negative or positive classes. We provide decision functions for Linear and Gaussian Kernel SVMs.

screenshot

  • q : Quit demo
  • left click : Add samples from red class
  • right click : Add samples from blue class
  • c : Clear training data
  • Space : Show/hide decision function
  • m : Change classifier (Linear/Gaussian SVM)
  • Up : Make Gaussian Gamma parameter larger
  • Down : Make Gaussian Gamma parameter smaller
  • s : save screenshot

Dependencies:

This demo uses pygame for visualization and Scikit-learn for classification.

Style Transfer Demo

In this demonstration we illustrate style transfer on image taken from the webcam. You can choose among several styles.

The implementation for style transfer has been shamelessly copied from Pytorch_WCT that is an implementation of the paper Universal Style Transfer via Feature Transforms.

Computational time for transfer takes a few seconds on a laptop with no GPU and freeze the windows.

screenshot

  • q : Quit demo
  • p : Take picture/unfreeze webcam
  • s : Switch target style
  • Space : Apply selected style
  • w : Save images to disk (folder out/)
  • r : Run transfer for all styles and save to file (takes forever)

Dependencies:

This demo uses opencv-python for webcam access and visualization and torch/torchvision as deep learning framework.

Discrete Optimal Transport demo

In this demonstration we plot in real time the solution of optimal transport (OT) between discrete distributions. The samples from source can be added by a left clock and samples from target distribution can be added by a right click.

screenshot

Shortcuts:

  • q or Esc : Quit demo
  • Space : Show/Hide the optimal transport matrix
  • c : Clear all samples
  • r : Activate/deactivate entropic regularization
  • p or m : Increase or decrease regularization parameter
  • t : Rotate the target distribution
  • e : remove some samples so that they have equal number
  • d : change the metric in OT loss

Dependencies:

This demo uses pygame for visualization and POT for computing the solution of the OT problem.

Face detection

In this demo we use a Haar Cascade Classifier to detect faces and show the areas where a face was detected. We use the default face classifier from OpenCV that detect only frontal faces.

screenshot

  • q : Quit demo
  • s : Save screenshot

This demo uses opencv-python for webcam access and visualization.

Installing dependencies

There is an important number of dependencies to run all the demos. Each script has its own dependencies. To print the list of dependencies for a given demo you can run:

python3 demo.py -d [demo_name]

About

Real time python demonstrations for machine learning, image and signal processing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages