目录
目录README.md

🖼️ Jittor Conditional GAN (cGAN)

🌟 A Conditional Generative Adversarial Network (cGAN) implemented using Jittor, designed for generating digit images on the MNIST dataset. Control the generated images via conditional input (class labels), combined with custom data augmentation and training strategies.

📚 Overview

This project implements a simple yet powerful Conditional GAN focusing on generating handwritten digit images on the MNIST dataset. The model architecture includes:

  • Generator: Transforms random noise and digit labels into realistic digit images.
  • Discriminator: Determines the authenticity of input images along with their corresponding labels.
  • Powered by Jittor framework for dynamic computation graphs and auto-differentiation.

🛠️ Installation

1️⃣ Clone this repository:

git clone https://www.gitlink.org.cn/guanning/cgan
cd cgan

2️⃣ Install dependencies:

pip install jittor

3️⃣ (Optional) To enable GPU support:

import jittor as jt
if jt.has_cuda:
    jt.flags.use_cuda = 1

🚀 Usage

1️⃣ Train the model:

python your_script.py --n_epochs 100 --batch_size 64

2️⃣ Generate digit images:

  • During training, sample images will be saved at intervals (e.g., 1000.png).
  • The final generated image will be saved as result.png, showcasing multiple digits.

🏗️ Model Architecture

🎨 Generator

  • Embedding layer: Encodes labels into vector space.
  • Fully connected layers (with BatchNorm and LeakyReLU).
  • Output: Tanh activation for image generation.

🔍 Discriminator

  • Embedding layer: Encodes labels.
  • Fully connected layers (with Dropout and LeakyReLU).
  • Output: Sigmoid activation for binary classification (real/fake).

📂 Project Structure

cgan/
├── CGAN.py # Main training script
├── README.md # This README file
├── .gitignore # Git ignore file
├── (0.png/1000.png/.../result.png) # Sample generated images
└── (generator_last.pkl/discriminator_last.pkl) # Saved models
关于

“计图挑战赛”热身题目 & Homework PA3, Introduction to Computer Graphics, 2025 Spring

40.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号