All Projects → floydhub → Dcgan

floydhub / Dcgan

Licence: bsd-3-clause
Porting pytorch dcgan on FloydHub

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Dcgan

Pytorch Mobilenet V3
MobileNetV3 in pytorch and ImageNet pretrained models
Stars: ✭ 616 (+2833.33%)
Mutual labels:  imagenet
Addernet
Code for paper " AdderNet: Do We Really Need Multiplications in Deep Learning?"
Stars: ✭ 722 (+3338.1%)
Mutual labels:  imagenet
Mini Imagenet
Generate mini-ImageNet with ImageNet for fewshot learning
Stars: ✭ 22 (+4.76%)
Mutual labels:  imagenet
Efficientnet Pytorch
A PyTorch implementation of EfficientNet and EfficientNetV2 (coming soon!)
Stars: ✭ 6,685 (+31733.33%)
Mutual labels:  imagenet
Caffenet Benchmark
Evaluation of the CNN design choices performance on ImageNet-2012.
Stars: ✭ 700 (+3233.33%)
Mutual labels:  imagenet
Gans In Action
Companion repository to GANs in Action: Deep learning with Generative Adversarial Networks
Stars: ✭ 748 (+3461.9%)
Mutual labels:  dcgan
Cvat
Powerful and efficient Computer Vision Annotation Tool (CVAT)
Stars: ✭ 6,557 (+31123.81%)
Mutual labels:  imagenet
Classification models
Classification models trained on ImageNet. Keras.
Stars: ✭ 938 (+4366.67%)
Mutual labels:  imagenet
Keras Idiomatic Programmer
Books, Presentations, Workshops, Notebook Labs, and Model Zoo for Software Engineers and Data Scientists wanting to learn the TF.Keras Machine Learning framework
Stars: ✭ 720 (+3328.57%)
Mutual labels:  dcgan
Tensorlayer
Deep Learning and Reinforcement Learning Library for Scientists and Engineers 🔥
Stars: ✭ 6,796 (+32261.9%)
Mutual labels:  imagenet
Randwirenn
Implementation of: "Exploring Randomly Wired Neural Networks for Image Recognition"
Stars: ✭ 675 (+3114.29%)
Mutual labels:  imagenet
Deeplearningmugenknock
でぃーぷらーにんぐを無限にやってディープラーニングでDeepLearningするための実装CheatSheet
Stars: ✭ 684 (+3157.14%)
Mutual labels:  dcgan
Pytorch image classification
PyTorch implementation of image classification models for CIFAR-10/CIFAR-100/MNIST/FashionMNIST/Kuzushiji-MNIST/ImageNet
Stars: ✭ 795 (+3685.71%)
Mutual labels:  imagenet
Hrnet Image Classification
Train the HRNet model on ImageNet
Stars: ✭ 633 (+2914.29%)
Mutual labels:  imagenet
Imagenetscraper
👁 Bulk-download all thumbnails from an ImageNet synset, with optional rescaling
Stars: ✭ 24 (+14.29%)
Mutual labels:  imagenet
Label Studio
Label Studio is a multi-type data labeling and annotation tool with standardized output format
Stars: ✭ 7,264 (+34490.48%)
Mutual labels:  imagenet
Context Encoder
[CVPR 2016] Unsupervised Feature Learning by Image Inpainting using GANs
Stars: ✭ 731 (+3380.95%)
Mutual labels:  dcgan
Dcgan Tensorflow
A tensorflow implementation of "Deep Convolutional Generative Adversarial Networks"
Stars: ✭ 6,963 (+33057.14%)
Mutual labels:  dcgan
Orange3 Imageanalytics
🍊 🎑 Orange3 add-on for dealing with image related tasks
Stars: ✭ 24 (+14.29%)
Mutual labels:  imagenet
Switchable Normalization
Code for Switchable Normalization from "Differentiable Learning-to-Normalize via Switchable Normalization", https://arxiv.org/abs/1806.10779
Stars: ✭ 804 (+3728.57%)
Mutual labels:  imagenet

Deep Convolutional Generative Adversarial Networks - DCGANs

Generated images from noise on LFW ds after 300 epochs

This project implements the paper Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks from a porting of pytorch/examples/dcgan making it usables on FloydHub.

The implementation is very close to the Torch implementation dcgan.torch.

Before start, the fixed_noise.pth (serialized Z vector used for generating image on training) is saved in the outf folder.

After every 100 training iterations, the files real_samples.png and fake_samples.png are written to disk with the samples from the generative model.

After every epoch, models are saved to: netG_epoch_%d.pth and netD_epoch_%d.pth

Downloading the LSUN dataset

You can download the LSUN dataset by cloning this repo and running

python download.py -c bedroom

Usage

Training script:

usage: main.py [-h] --dataset DATASET --dataroot DATAROOT [--workers WORKERS]
               [--batchSize BATCHSIZE] [--imageSize IMAGESIZE] [--nz NZ]
               [--ngf NGF] [--ndf NDF] [--niter NITER] [--lr LR]
               [--beta1 BETA1] [--cuda] [--ngpu NGPU] [--netG NETG]
               [--netD NETD]

optional arguments:
  -h, --help            show this help message and exit
  --dataset DATASET     cifar10 | lsun | imagenet | folder | lfw
  --dataroot DATAROOT   path to dataset
  --workers WORKERS     number of data loading workers
  --batchSize BATCHSIZE
                        input batch size
  --imageSize IMAGESIZE
                        the height / width of the input image to network
  --nz NZ               size of the latent z vector
  --ngf NGF
  --ndf NDF
  --niter NITER         number of epochs to train for
  --lr LR               learning rate, default=0.0002
  --beta1 BETA1         beta1 for adam. default=0.5
  --cuda                enables cuda
  --ngpu NGPU           number of GPUs to use
  --netG NETG           path to netG (to continue training)
  --netD NETD           path to netD (to continue training)

Generating script:

usage: generate.py [-h] --netG NETG [--outf OUTF] [--Zvector ZVECTOR] [--cuda]
                   [--ngpu NGPU]

optional arguments:
  -h, --help         show this help message and exit
  --netG NETG        path to netG (for generating images)
  --outf OUTF        folder to output images
  --Zvector ZVECTOR  path to Serialized Z vector
  --cuda             enables cuda
  --ngpu NGPU        number of GPUs to use

DCGAN Architecture

DCGAN

Run on FloydHub

Follow the tutorial on the FloydHub docs or follow the next steps:

Project Setup

Before you start, log in on FloydHub with the floyd login command, then fork and init the project:

$ git clone https://github.com/floydhub/dcgan.git
$ cd dcgan
$ floyd init dcgan

Training

This project support the following datasets which were used in the paper:

  • LSUN, coming soon on FloydHub Dataset, but you can download it following the above command
  • CIFAR-10, available on FloydHub here
  • ImageNet, available on FloydHub here
  • LFW, available on FloydHub here
  • Custom Image Dataset Folder, now it's your turn to make new experiments :)

Now it's time to run our training on FloydHub. In this example we will train the model for 100 epochs with a gpu instance and with cuda enabled. Note: If you want to mount/create a dataset look at the docs.

$ floyd run --gpu --env pytorch-0.2  --data redeipirati/datasets/lfw/1:lfw "python main.py --dataset lfw --dataroot /lfw --outf trained_models --cuda --ngpu 1 --niter 100

You can follow along the progress by using the logs command. The training should take about 2h!!

Evaluating

It's time to evaluate our model generating some images:

floyd run --gpu --env pytorch-0.2  --data <REPLACE_WITH_JOB_OUTPUT_NAME>:/model "python generate.py --netG /model/trained_models/<REPLACE_WITH_MODEL_CHECKPOINT_PATH> --ngpu 1 --cuda"

# Provide a serialized Zvector
floyd run --gpu --env pytorch-0.2  -data <REPLACE_WITH_JOB_OUTPUT_NAME>:/model "python generate.py --netG /model/trained_models/<REPLACE_WITH_MODEL_CHECKPOINT_PATH> --Zvector <REPLACE_WITH_SERIALIZED_Z_VECTOR_PATH> --ngpu 1 --cuda"

Try our pre-trained model

We have provided to you a pre-trained model trained on the lfw-dataset for about 300 epochs.

floyd run --gpu --env pytorch-0.2  --data redeipirati/datasets/dcgan-300-epochs-models/1:/model "python generate.py --netG /model/netG_epoch_299.pth --ngpu 1 --cuda"

Serve model through REST API

If you run a job with --mode serve flag, FloydHub will run the app.py file in your project and attach it to a dynamic service endpoint:

floyd run --gpu --mode serve --env pytorch-0.3  --data <REPLACE_WITH_JOB_OUTPUT_NAME>:/input

The above command will print out a service endpoint for this job in your terminal console.

The service endpoint will take a couple minutes to become ready. Once it's up, you can interact with the model by sending serialized Z vector file with a POST request or simply generating images from random noise:

# e.g. of a GET req
curl -X GET -o <NAME_&_PATH_DOWNLOADED_IMG> -F "ckp=<MODEL_CHECKPOINT>" <SERVICE_ENDPOINT>
curl -X GET -o prova.png -F "ckp=netG_epoch_99.pth" https://www.floydlabs.com/serve/redeipirati/projects/dcgan

# e.g. of a POST req
curl -X POST -o <NAME_&_PATH_DOWNLOADED_IMG> -F "[email protected]<ZVECTOR_SERIALIZED_PATH>" <SERVICE_ENDPOINT>
curl -X POST -o prova.png -F "[email protected]/parameter/zvector.pth" https://www.floydlabs.com/serve/redeipirati/projects/dcgan

Any job running in serving mode will stay up until it reaches maximum runtime. So once you are done testing, remember to shutdown the job!

More resources

Some useful resources on DCGAN:

Contributing

For any questions, bug(even typos) and/or features requests do not hesitate to contact me or open an issue!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].