Switch branches/tags
Find file History
Latest commit 28c6c8c Oct 5, 2018
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.ipynb_checkpoints update the readme file Aug 12, 2018
cats_model update cats model Aug 22, 2018
cats_model_small add smaller model for cats Aug 24, 2018
celeb_model add celebrity face model/ remove previous face models Sep 14, 2018
datasets add pokemon dataset Aug 22, 2018
facades_model add facades model Aug 11, 2018
frozen_model Delete tmp Aug 6, 2018
pokemon_model add pokemon model Aug 22, 2018
scene_model add scene model Sep 1, 2018
shoes_model update models Aug 11, 2018
README.md Update README.md Sep 17, 2018
cat.png update models Aug 11, 2018
cats.html add celebrity face model/ remove previous face models Sep 14, 2018
celeb.html Update celeb.html Oct 5, 2018
celeb.png add celebrity face model/ remove previous face models Sep 14, 2018
convert_keras.py Add files via upload Sep 7, 2018
facade.png update models Aug 11, 2018
facades.html add celebrity face model/ remove previous face models Sep 14, 2018
facades.js minor fixes Aug 23, 2018
faceSeg.html add celebrity face model/ remove previous face models Sep 14, 2018
faceSeg.js add celebrity face model/ remove previous face models Sep 14, 2018
main.css add new semantic map of faces Aug 27, 2018
main.js add scene model Sep 1, 2018
pix2pix.gif Add files via upload Sep 7, 2018
pokemon.html add celebrity face model/ remove previous face models Sep 14, 2018
pokemon.png add pokemon model Aug 22, 2018
scene.html add celebrity face model/ remove previous face models Sep 14, 2018
scene.png add scene model Sep 1, 2018
shoe.png update models Aug 11, 2018
shoes.html add celebrity face model/ remove previous face models Sep 14, 2018
tf.min.js Add files via upload Aug 9, 2018
tf_pix2pix.ipynb Add files via upload Sep 7, 2018

README.md

Implementation of pix2pix

alt text

Demo

Check here https://zaidalyafeai.github.io/pix2pix/celeb.html

Implementation

Based on the Tensorflow implementation

https://github.com/affinelayer/pix2pix-tensorflow

Training

Use tf_pix2pix.ipynb notebook for training. You can run it on colab using this link

https://colab.research.google.com/github/zaidalyafeai/zaidalyafeai.github.io/blob/master/pix2pix/tf_pix2pix.ipynb

Training depends on the dataset. Here you can find many datasets

https://people.eecs.berkeley.edu/~tinghuiz/projects/pix2pix/datasets/

Make sure to choose the correct direction AtoB or BtoA depending on the dataset.

Convert the model to TensorFlow.js

  1. First export the model by changing the mode to export. This will create export files.
  2. use the convert_keras.py script to convert the model to keras python convert_keras.py --dir input_dir --out output_dir
  3. Install tensorflowjs package using pip install tensorflowjs
  4. Convert the model

tensorflowjs_converter --input_format keras keras.h5 output_directory

Train on your dataset

Use these scripts

https://github.com/zaidalyafeai/pix2pix/tree/master/scripts/edges

The process first uses a caffe model to create mat files. Then you can use matlab to generate edges. If you faced some difficulties with that you can use cv2.canny to extract the edge map of the input iamges.

Processed Dataset

Check cats.zip which contains 1000 images of cats. It was obtained from http://www.robots.ox.ac.uk/~vgg/data/pets/ by first using the segmentation to extract the cats and replace the background with white. Then the previous step was used to generate the edges.

Also, pokemon.zip contains 800 images of Pokemons that were optained from https://www.kaggle.com/kvpratama/pokemon-images-dataset. The edges were extracted using canny edge extractor.