Inofficial implementation of the paper "SinGAN: Learning a Generative Model from a Single Natural Image" as a project for the Deep Generative Models lecture at TU Darmstadt SS2020.
In order to execute the web application on your local computer, you need to do the following.
- Install all packages from the
requirements.txt
. - Install the RabbitMQ message broker from their website.
- Run the RabbitMQ Service, then open a terminal and configure RabbitMQ by entering the following four commands:
rabbitmqctl.bat add_user singan singan
rabbitmqctl.bat add_vhost singan_host
rabbitmqctl.bat set_user_tags singan singan_tag
rabbitmqctl.bat set_permissions -p singan_host singan ".*" ".*" ".*"
- In the project's root directory, go into the folder
web
, open a terminal here and runpython manage.py runserver
to run the Django server. - In the same folder (
web
) open another terminal and execute the Celery worker process by enteringcelery -A web worker --pool=solo -l info
- Finally, in your browser, open http://127.0.0.1:8000/.
For each of the SinGAN applications, we created an easy-to-use python script that can be run directly from the console by specifying the necessary parameters. All of these scripts have in common that they require either just the run_name of a pretrained SinGAN model or the --not_pretrained
flag together with the training image path, the number of scales N and the number of steps per scale. For instance, the following additional command line arguments would train a SinGAN model on the green fern plant image with 8 scales and 2000 steps per scale:
python application.py [...] --not_pretrained --img 5026-green-fern-plant-during-daytime.jpg --N 8 --steps_per_scale 2000
If the --not_pretrained
flag is not given but a trained model with the identifier run_name
exists, this is used instead.
python sample.py --run_name <String> -- height <int> --width <int>
python scale_injections.py --run_name <String>
python scale_injections.py --run_name <String> --super_scales <int>
Note: You have to additionally provide a training image via --img
if you want to train a new model. The paint images are expected to be found in the data/paint subdirectory.
python paint2image.py --run_name <String> --paint 5026_1.jpg
python animate.py --run_name <String> --frames <int> --fps <int> --alpha 0.1 --beta 0.9 --start_at_scale <int>
training (512x512) | 512x512 | 512x512 | 512x512 | 512x1024 |
---|---|---|---|---|
training (512x512) | Scale 0/10 | Scale 1/10 | Scale 2/10 | Scale 3/10 | Scale 4/10 |
---|---|---|---|---|---|
Scale 5/10 | Scale 6/10 | Scale 7/10 | Scale 8/10 | Scale 9/10 | Scale 10/10 |
---|---|---|---|---|---|
training (512x512) | Scale 0/10 | Scale 1/10 | Scale 2/10 | Scale 3/10 | Scale 4 |
---|---|---|---|---|---|
Scale 5/10 | Scale 6/10 | Scale 7/10 | Scale 8/10 | Scale 9/10 | Scale 10/10 |
---|---|---|---|---|---|
training (512x512) | SinGAN (1616x1616) | bilinear (1616x1616) |
---|---|---|
training | paint | Scale 7/9 | Scale 9/9 |
---|---|---|---|
training | paint | Scale 6/9 | Scale 9/9 |
---|---|---|---|
training | paint | Scale 6/9 | Scale 9/9 |
---|---|---|---|
training | animation |
---|---|