Skip to content

Class Project using Deep Learning and GANs

Notifications You must be signed in to change notification settings

swoolf/sketchgan2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

To Run:

    python pix2pix_.py --mode train --output_dir /a/data/grp1/two_n_ --max_epochs 100 --input_dir /a/data/grp1/sketch_photo_pairs/train/ --which_direction AtoB --save_freq 1000 --display_freq 500

In tools directory:

-incpetion_score.py
    Calculates inception score for images in input directory

-combine.py
	Creates input data by putting sketches and photos side by side in a single png

-move.py
	Moves images from images folder into batch directories

-collage.py
	Takes images from a batch and puts them into one png
	Makes three files for input, output, and target images

-gen_val2.py
	Takes generated images and runs them through Inception classifier
	Need to change input_dir line in main
	Prints misclassified data, Top 1 accuracy, and Top 5 accuracy

-gen_val3.py
	Takes generated images and runs them through Inception classifier
	Need to change input_dir line in main
	Dumps top1/top5 accuracy by class to a json
	Need to change output_file in run_inference

Models:

- pix2pix_2n.py
    Discrim loss: real/fake cross entropy + class cross entropy
    Generator loss: fake cross entropy + class cross entropy
    Treats both sides of 2n vector as n classes, disregards real/fake

- pix2pix_penalty2.py
    Discrim loss: (2N real cross entropy + 2N fake cross entropy) * penalties
    Generator loss: 2N fake cross entropy * penalties + L1 distance
    No unsupervised loss

    

POTENTIAL EXPERIMENTS:
     X  1. N+1 loss (baseline)  (pix2pix_nplus1.py)
        2. Inception scoring
     X  3. Combine classes in loss for 2N (pix2pix_2n.py)
		-Discrim loss: real/fake cross entropy + class cross entropy
		-Generator loss: fake cross entropy + class cross entropy
     X  4. Remove real/fake in loss for penalties (pix2pix_penalty2.py)
		-Discrim loss: (2N real cross entropy + 2N fake cross entropy) * penalties
		-Generator loss: 2N fake cross entropy * penalties + L1 distance
        5. Preprocess original photos with image segmentation  [Sam]
     X  6. Make penalty mask a function
     X  7. Add class condition to generator with just real/fake discriminator (pix2pix_cond_n.py)

** pix2pix_cond_n.py and pix2pix_2n.py and pix2pix_penalty2.py are untested but should be ready to run as soon as a gpu opens up
** pix2pix_penalty2.py has a separate function for getting the penalty mask, should copy over to pix2pix_penalty.py once tested
** N+1 also done but not tested

Paper:
    file_name, data_directory

    ======== Base Line =========
    1. pix2pix_orig.py, orig: out of the box version (seems to generate the
      best images). discrim: real / fake, gen: real / fake
      (Running on GPU 8)

    ======== Improved Techniques GANs (N+1)  ======
    2. pix2pix_nplus1.py, nplus1: baseline model
    (Running on GPU 1)

    ======== 2n output layer =======
    3a. pix2pix_rf_class.py, 2n: discrim - class loss cross entropy and real fake
      generator - class loss and real fake 

    XXX3b. two_n2: discrim: real fake + 2n, gen: real fake 

    3c. pix2pix_2n2n.py, 2n2n: discrim: 2n, 2n
    
    3d. 2n_rf: discrim: real fake + 2n, gen: real fake + 2n

    ======== Conditional pix2pix =====
    4a. pix2pix_cond_n.py, cond_n: basline discriminator with class conditional
    generator (TODO: if this is better than Base Line add it to 2N below)

    4b. pix2pix_cond_nplus1.py, : conditional with nplus1 loss

    XXX4b. pix2pix_cond.py, two_n_cond: conditional generator, has real fake 
    loss and 2n loss. TODO: get rid of real fake loss

    ======== Penalty =======
    5a. pix2pix_pen.py, pen: 2n loss (no real fake) and penalty

    XXX5b. pix2pix_penalty.py, two_n_pen: 2n loss with penalty and real fake loss

    - two_n: ??? 

    ======== Super Model =====

    6. TODO: take best of penalty (yes no) and conditional (yes no)

    ======= Pre-Processing: Segmentation Mask =======

    7. TODO: runn on Baseline, N+1, and Super Model

    ========= Evaluation =======

    8. TODO: inception score + qualitative + semi-supervised classification accuracy
    inception scores:
        1. all original photos: ('scores mean:', 9.1729546, ' scores std:', 0.90772361)
        2. validation photos: ('scores mean:', 74.813187, ' scores std:', 1.4033152)
        3. orig: ('scores mean:', 5.2578478, ' scores std:', 0.12857515)
        4. orig2: ('scores mean:', 5.2614627, ' scores std:', 0.16161911)
        5. 2n2n: ('scores mean:', 6.1084046, ' scores std:', 0.11478753)
        6. 2n: ('scores mean:', 5.0989408, ' scores std:', 0.11322323)
        7. pen: ('scores mean:', 6.4307909, ' scores std:', 0.19561777)
        8. pen2: ('scores mean:', 6.2003007, ' scores std:', 0.10216211)
        9. cond_n: ('scores mean:', 4.2493067, ' scores std:', 0.074722126)
        10. image_seg: ('scores mean:', 5.9599605, ' scores std:', 0.24508114)
        11. image segmented validation photos: ('scores mean:', 13.329549, ' scores std:', 0.89784962)
    generated images accuracy:
        1. all original photos:
        2. validation photos: (Accuracy: 0.719030437598 Top 5: 0.790359885281)
        3. orig: (Accuracy: 0.00860394116014 Top 5: 0.0263669164585)
        4. orig2: (Accuracy: 0.00832639467111 Top 5: 0.0235914515681)
        5. 2n2n: (Accuracy: 0.00481080580997 Top 5: 0.0189656767509)
        6. 2n: (Accuracy: 0.00582847626978, Top 5: 0.0221112036266)
        7. pen: (Accuracy: 0.00962161161995, Top 5 Accuracy: 0.0271070404293)
        8. pen2: (Accuracy: 0.0085114256638, Top 5: 0.0244240910352)
        9. cond_n: (Accuracy: 0.0105467665834, Top 5: 0.0312702377648)
        10. image_seg: (Accuracy: 0.0198717948718, Top 5 Accuracy: 0.0442307692308)
	11. image segmented validation photos: (Accuracy: 0.405769230769, Top 5: 0.605128205128)
    discriminator accuracy:
        1. all original photos:
        2. validation photos:
        3. orig:
        4. orig2:
        5. 2n2n: 0.269785502959
        6. 2n: 0.0183062130178
        7. pen: 0.102625739645
        8. pen2: 0.290865384615
        9. cond_n:
        10. image_seg:
	11. image segmented validation photos:

About

Class Project using Deep Learning and GANs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.6%
  • HTML 2.9%
  • HCL 0.5%