Coder Social home page Coder Social logo

jonasgrebe / pt-singan-single-image-gan Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 464.17 MB

Inofficial implementation of the paper "SinGAN: Learning a Generative Model from a Single Natural Image"

Python 26.56% CSS 7.32% JavaScript 59.81% HTML 6.31%
singan gan inoffical pytorch generative-adversarial-network image-super-resolution image-translation image-editing image-harmonization single-image-animation

pt-singan-single-image-gan's Introduction

pt-singan-single-image-gan

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.

The web application

Setup

In order to execute the web application on your local computer, you need to do the following.

  1. Install all packages from the requirements.txt.
  2. Install the RabbitMQ message broker from their website.
  3. 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 ".*" ".*" ".*"
  4. In the project's root directory, go into the folder web, open a terminal here and run python manage.py runserver to run the Django server.
  5. In the same folder (web) open another terminal and execute the Celery worker process by entering celery -A web worker --pool=solo -l info
  6. Finally, in your browser, open http://127.0.0.1:8000/.

How to use without the UI

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.

Random Sampling

python sample.py --run_name <String> -- height <int> --width <int>

Scale Injection

python scale_injections.py --run_name <String>

Super Resolution

python scale_injections.py --run_name <String> --super_scales <int>

Paint2Image

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

Single Image Animation

python animate.py --run_name <String> --frames <int> --fps <int> --alpha 0.1 --beta 0.9 --start_at_scale <int>

Current example results

Random Sampling

training (512x512) 512x512 512x512 512x512 512x1024
train img1 img2 img3 img4
train img1 img2 img3 img4
train img1 img2 img3 img4

Scale Injections

training (512x512) Scale 0/10 Scale 1/10 Scale 2/10 Scale 3/10 Scale 4/10
train img1 img2 img3 img4 img5
Scale 5/10 Scale 6/10 Scale 7/10 Scale 8/10 Scale 9/10 Scale 10/10
train img6 img7 img8 img9 img10
training (512x512) Scale 0/10 Scale 1/10 Scale 2/10 Scale 3/10 Scale 4
train img1 img2 img3 img4 img5
Scale 5/10 Scale 6/10 Scale 7/10 Scale 8/10 Scale 9/10 Scale 10/10
train img6 img7 img8 img9 img10

Super Resolution

training (512x512) SinGAN (1616x1616) bilinear (1616x1616)
train img1 img2
train img1 img2
train img1 img2

Paint2Image

training paint Scale 7/9 Scale 9/9
train img1 img2 img3
training paint Scale 6/9 Scale 9/9
train img1 img2 img3
training paint Scale 6/9 Scale 9/9
train img1 img2 img3

Single Image Animation

training animation
train img1

pt-singan-single-image-gan's People

Contributors

jonasgrebe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.