Skip to content

ncassereau/pictures-optimal-transport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pictures Optimal Transport

What is this repository ?

This repository uses optimal transport to compute the transformation between a picture and another. It is based on this code through the usage of POT. However, this repository contains the full code to generate such a video.

How to use it ?

In order to use to it, you should change the configuration to your liking by modifying conf.py. It includes parameters for the transportation as well as the computation itself (SLURM parameters if you're using such a job scheduler).

With SLURM

If SLURM is available, you can launch the computation by executing the following in the src/ folder.

python3 launcher.py

This script will create a submission file for SLURM.

Without SLURM

You can just launch the multiple scripts in the following order (inside the src/ folder):

python3 transport.py
python3 make_pics.py
python3 merge_pics.py

A notebook is also available, although it does not contain every feature of the script version (such as easing functions or the ability to handle more than 2 pictures to create a cycle). As such, the script version is recommended. The notebook can be very handy to try several parameters to get high quality pictures, such as points size or the contrast level.

After the computation, it is strongly advised to compress it, for instance with gifsicle. Such software is not available on Jean Zay, that is why it was not included in the code. You could for instance run the following:

gifsicle -O3 --colors 16 --lossy=200 mygif.gif > optimized.gif

In order to have a reasonable file size, you probably should also limit to 30 fps.

Examples

Here are a few examples computed with 40k points.

picture of Monge picture of Kantorovich Monge-Kantorovich transport


picture of Charlie the Unicorn picture of Pink Unicorn picture of Blue Unicorn Unicorns transport


picture of Wojak picture of Chad Wojak-Chad transport

About

Using optimal transport to morph pictures in a cycle.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published