Skip to content

Commit

Permalink
Merge pull request #8 from hoangbros03/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
hoangbros03 authored Dec 8, 2023
2 parents c3856db + 77547c1 commit b66181b
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 10 deletions.
Binary file modified Midterm_Report.pdf
Binary file not shown.
25 changes: 21 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
# Introduction

This repository contains our GAN implementations, reports, and experiment results for the mid-term project of INT3412E 20 in VNU-UET
This repository contains our GAN (Generative Adversarial Network) implementations, reports, and experiment results for the mid-term project of INT3412E 20 in VNU-UET.

# Description

We provided two version of GAN: The original GAN with Multi Layer Perception layers and the enhanced GAN using Convolutional Neural Network layers. People can train, test, and generate the images within few commands and don't need a deep understanding of GAN.

MNIST and CelebA datasets were used and tested. Other datasets also can be used, but require a few changes in the dataloader class. We welcome any improvement to this repo.

# Authors

This repository was made by two VNU-UET students:

[Nguyen Binh Nguyen](https://github.com/nguyenrtm)

[Tran Ba Hoang](github.com/hoangbros03)


# Usage

Before using, please clone this repo, install the requirements, and install this repo as a pip package
## Installation

Before using, please clone this repo, install the requirements, and install this repo as a pip package.

```
// (Optional) Create a new conda environment
conda create -n gan_env
conda activate gan_env
// Clone and install the necessary packages
git clone https://github.com/hoangbros03/GAN-implement.git
cd GAN-implement
pip install -r requirements.txt
Expand All @@ -29,17 +45,18 @@ cd src/pure_gan
python train.py -e 200 -b 64 --lr 0.0002 --latent_dim 100 --output_model_dir models
```

Feel free to change the config specified :D
If confused of configuration, please type `python train.py -h` to get the guide. Feel free to change the config specified :D

## Train the enhanced GAN

First, please make sure that celebA data is downloaded if you want to use the celebA dataset. It should has the following folder structure:
First, please make sure that celebA data is downloaded if you want to use the celebA dataset (this dataset is widely available on the Internet). It should has the following folder structure:

```
cnn_gan
├──data
├──celebA
├──image1.png
├──image2.png
...
├──imagen.png
```
Expand Down
7 changes: 4 additions & 3 deletions evaluate/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def convert_dataloader_to_sample(dataloader):
gt = batch_data[0]
else:
gt = torch.vstack((gt, batch_data[0]))

return gt
else:
return gt
return None


def unnormalize(tensor):
Expand Down Expand Up @@ -59,7 +60,7 @@ def kernel_inception_distance(prediction, gt):
Returns:
A number indicate the value from the specified metric
"""
kid = KernelInceptionDistance(subset_size=1)
kid = KernelInceptionDistance(subset_size=64)
kid.update(prediction, real=False)
kid.update(gt, real=True)
return kid.compute()
Expand Down
Binary file removed mnist/MNIST/raw/t10k-images-idx3-ubyte
Binary file not shown.
Binary file removed mnist/MNIST/raw/t10k-images-idx3-ubyte.gz
Binary file not shown.
Binary file removed mnist/MNIST/raw/t10k-labels-idx1-ubyte
Binary file not shown.
Binary file removed mnist/MNIST/raw/t10k-labels-idx1-ubyte.gz
Binary file not shown.
Binary file removed mnist/MNIST/raw/train-images-idx3-ubyte
Binary file not shown.
Binary file removed mnist/MNIST/raw/train-images-idx3-ubyte.gz
Binary file not shown.
Binary file removed mnist/MNIST/raw/train-labels-idx1-ubyte
Binary file not shown.
Binary file removed mnist/MNIST/raw/train-labels-idx1-ubyte.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion notebooks/celeb_a_experiment.ipynb

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions notebooks/mnist_experiment.ipynb

Large diffs are not rendered by default.

Binary file removed src/pure_gan/mnist/MNIST/raw/t10k-images-idx3-ubyte
Binary file not shown.
Binary file not shown.
Binary file removed src/pure_gan/mnist/MNIST/raw/t10k-labels-idx1-ubyte
Binary file not shown.
Binary file not shown.
Binary file removed src/pure_gan/mnist/MNIST/raw/train-images-idx3-ubyte
Binary file not shown.
Binary file not shown.
Binary file removed src/pure_gan/mnist/MNIST/raw/train-labels-idx1-ubyte
Binary file not shown.
Binary file not shown.

0 comments on commit b66181b

Please sign in to comment.