目录
目录README.md

Jittor_CGAN

计图挑战热身赛(手写数字生成赛题)

赛题简介

本赛道将在数字图片数据集 MNIST 上训练 Conditional GAN(Conditional generative adversarial nets)模型,通过输入一个随机向量 z 和额外的辅助信息 y (如类别标签),生成特定数字的图像。

赛题内容

本赛题将会提供数字图片数据集 MNIST,参赛选手需要训练一个将随机噪声和类别标签映射为数字图片的Conditional GAN模型,并生成注册时绑定的手机号(如果没有绑定手机号请先绑定再进行提交)。

运行环境

  • Ubuntu >= 16.04 或 Windows Subsystem of Linux(WSL)
  • python >= 3.7
  • jittor >= 1.3.0
  • C++编译器 (需要下列至少一个)
    • g++ (>=5.4.0)
    • clang (>=8.0)
  • GPU 编译器(可选):nvcc >=10.0
  • GPU 加速库(可选):cudnn-dev (cudnn开发版, 推荐使用tar安装方法,参考链接)

安装

1.导入代码

git clone https://github.com/Jittor/gan-jittor.git
cd gan-jittor/
sudo python3.7 -m pip install -r requirements.txt
cd competition/warm_up_comp
修改 CGAN.py 后,执行python CGAN.py使其运行

2.Jittor安装

  • 步骤一:选择您的后端编译器
    # g++  
    sudo apt install g++ build-essential libomp-dev
    # OR clang++-8  
    wget -O - https://raw.githubusercontent.com/Jittor/jittor/master/script/install_llvm.sh > /tmp/llvm.sh  
    bash /tmp/llvm.sh 8  
  • 步骤二:安装Python和python-dev Jittor需要python的版本>=3.7。
    sudo apt install python3.7 python3.7-dev  
  • 步骤三:运行Jittor 接下来将通过pip安装jittor
    git clone https://github.com/Jittor/jittor.git  
    sudo pip3.7 install ./jittor  
    export cc_path="clang++-8"  
    # if other compiler is used, change cc_path 
    # export cc_path="g++"  
    # export cc_path="icc"
    # run a simple test 
    python3.7 -m jittor.test.test_example 
    如果通过了测试,那么您的Jittor已经准备就绪。
  • 可选步骤四:启用CUDA 在Jittor中使用CUDA非常简单,只需设置环境值nvcc_path,如果没有设置该环境变量,Jittor会使用默认环境变量/usr/local/cuda/bin/nvcc去寻找 nvcc。
# replace this var with your nvcc location  
export nvcc_path="/usr/local/cuda/bin/nvcc"   
# run a simple cuda test  
python3.7 -m jittor.test.test_cuda 

运行结果

  • 训练结束后,模型的生成器保存为generator_last.pkl文件,模型的判别器保存为discriminator_last.pkl文件。
  • 生成的号码图像为result.png,如图所示:
    主要结果
关于

本项目将在数字图片数据集 MNIST 上训练 Conditional GAN(Conditional generative adversarial nets)模型,通过输入一个随机向量 z 和额外的辅助信息 y (如类别标签),生成特定数字的图像。Jittor 是一个基于即时编译和元算子的高性能深度学习框架,整个框架在即时编译的同时,还集成了强大的Op编译器和调优器,为模型生成定制化的高性能代码。

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

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