Difference between revisions of "DCGAN"

From Interaction Station Wiki
Jump to navigation Jump to search
Line 86: Line 86:
  
 
'''Optional'''
 
'''Optional'''
;batchSize=64
+
: batchSize=64
:''Batchsize - didn't get very good results with this over 128...''
+
:: ''Batchsize - didn't get very good results with this over 128...''
;noise=normal, uniform
+
: noise=normal, uniform
:''pass ONE Of these. It seems like normal works a lot better, though.''
+
:: ''pass ONE Of these. It seems like normal works a lot better, though.''
;nz=100
+
: nz=100
:''umber of dimensions for Z''
+
:: ''umber of dimensions for Z''
;nThreads=1
+
: nThreads=1
:''number of data loading threads''
+
:: ''number of data loading threads''
;gpu=1
+
: gpu=1
:''gpu to use (1 is default)''
+
:: ''gpu to use (1 is default)''
;name=experiment1
+
: name=experiment1
:''just to make sure you don't overwrite anything cool, change the checkpoint filenames with this''
+
:: ''just to make sure you don't overwrite anything cool, change the checkpoint filenames with this''
  
 
Example code to run
 
Example code to run

Revision as of 15:25, 16 January 2018

Generating images using A "Deep Convolutional Generative Adversarial Network"

In this tutorial we will be using a modified version of Soumith Chintala's torch implementation (https://github.com/soumith/dcgan.torch) of DCGAN - Deep Convolutional Generative Adversarial Network (https://arxiv.org/pdf/1511.06434.pdf) with a focus on generating images.

Getting started

Because training a DCGAN requires a lot of computing power, head over to the interaction station and sit behind the computer with the 'ml machineq' sticker. This computer runs a Ubuntu installation with (almost) every dependencies required to run some machine learning scripts/programs. In this tutorial I will be using blocks to make clear we are pressing some keys or typing some code. Example:

⊞
enter

This would mean you need to press the Windows (⊞) key, follwed by an 'enter'. A code block that begins with a dollar sign means you need to type the command in the terminal window we are using. Example:

$ python3 test.py

This would mean you need to type 'python3 test.py' in the terminal window, without the dollar sign, this is just for indicating we're talking about the terminal window.

DCGAN

1: Log in to the computer by using the 'interactionstation' account.

username: interactionstation
password: interactionstation

2: Start a new 'terminal' window by pressing the windows key (⊞) and typing 'term', followed by pressing 'enter'

⊞
term
enter

Dcgan 1.png

3: Navigate to the folder where the DCGAN script is stored (/home/interactionstation/dcgan.epoch)

$ cd dcgan.epoch

Dcgan 2.png

4: If you have your own dataset ready, you can skip part 4 till part ...

This script also includes a dataset downloader. This allows you to download from Wikiart based on their genres. The usage is quite simple, but requires a bit of attention. In the script 'genre-scraper.py' there is a variable called 'genre_to_scrape' - simply change that to any of the genres listen on the Wikiart [1] website. After changing the variable to the desired genre, run the script with python3. This will create a folder named after the genre inside '/home/interactionstation/dcgan.epoch/', containing all the download images. Note: the script takes a while to finish!

Dcgan 3.png

$ sudo nano genre-scraper.py

Dcgan 4.png

Use the arrow keys to move the variable 'genre_to_scrape' and change it to the desired genre from Wikiart. Example:

genre_to_scrape = "nude-painting-nu"

Dcgan 5.png

Dcgan 6.png

Save the changes you've made by pressing the following keys in the same order

ctrl+X
Y
enter

Dcgan 7.png Dcgan 8.png

Run the script! Note: this is going to take a while, grab a coffee.

python3 genre-scraper.py

Dcgan 9.png

The script is done when terminal allows you to type some new commands.

Dcgan 10.png

5: If you want to use a dataset collected by yourself, please move to step 5b. Now we can finally train the DCGAN on our downloaded images! Since the script 'genre-scraper.py' does all the hard work for us, we only need to pass one command through terminal to train the DCGAN. There are a lot of options available for you to experiment with, so please try!

Required DATA_ROOT=nude-painting-nu This needs to be set to the downloaded genre from WIkiart dataset=folder All the images are in a folder, the DCGAN needs to know that ndf=50 The number of filters in the discriminators first layer ngf=150 The number of filters in the generators first layer, this needs to be around two times the number of the discriminator to prevent the discriminator from beating the generator out, since the generator has a much much much harder job

Optional

batchSize=64
Batchsize - didn't get very good results with this over 128...
noise=normal, uniform
pass ONE Of these. It seems like normal works a lot better, though.
nz=100
umber of dimensions for Z
nThreads=1
number of data loading threads
gpu=1
gpu to use (1 is default)
name=experiment1
just to make sure you don't overwrite anything cool, change the checkpoint filenames with this

Example code to run

$ DATA_ROOT=nude-painting-nu dataset=folder ndf=50 ngf=150 name=nuuuuuude_paintings


5b: