Code Monkey home page Code Monkey logo

cat_gen's Introduction

Cat Generator using DCGAN

The purpose of this project is generation cats images. To do so, I used a GAN model, specificaly a DCGAN model. The DCGAN generator takes a vector z from the latent space and uses transpose convolution to map the features and output an image of size 3x64x64. The discriminator uses the same procedure but inverted. image

I used a public dataset available here: https://www.kaggle.com/datasets/crawford/cat-dataset

The model was trained on 225 epochs with a dataset of size around 9000 images.

Modification were added in the training and dataset to avoid collapse mode:

  • Preprocessing of the data: Center around the face of the cat and crop the dataset to 64x64 size (Highly helped the model to converge)
  • Change of loss function from log(1-D(G(z))) to -log(D(G(z))) for the generator part (thanks to https://github.com/soumith/ganhacks)

Setup

pip install -r requirements.txt

Training

To run the training

python ./src/train_dcgan.py

Generate samples from the generator

To generate 64 cats from dcgan

In config.yaml, choose a checkpoint for the generator (default is "./saved_model/generator_checkpoint_225.pt") and run

python ./src/generate_fake.py

The generation plot should be saved in ./plots folder as sample_from_generator.png

Results

Results can be found in the ./plots folder

image

Source

For training: https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html

For preprocessing: https://github.com/AlexiaJM/Deep-learning-with-cats

Author

Mathieu Nalpon

cat_gen's People

Contributors

mathieunlp avatar

Watchers

 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.