Skip to content

lyqcom/biggan

Repository files navigation

Contents

[Model Description](#Model Description)

Dataset

Features

​ [Mixed Precision](#Mixed Precision)

[Environment Requirements](#Environment Requirements)

[Script Description](#Script Description)

[Model Train](#Model Train)

[Model Eval](#Model Eval)

[Model Infer](#Model Infer)

​ [Model Export](#Model Export)

​ [Run Infer](#Run Infer)

[Model Description](#Model Description)

[Description of Random Situation](#Description of Random Situation)

[Model_Zoo Homepage](#Model_Zoo Homepage)

Model Description

The generative adversarial network consists of a generator G and a discriminator D. The function of the former is to generate realistic random samples based on random noise data, and the function of the latter is to identify whether the samples are real or generated by the generator. The feat of BigGAN is achieved through large batches, large parameters, "truncation trick" and large-scale GAN training stability control.

Dataset

ImageNet2012 Dataset

  • Dataset size: 224*224 colorful images in 1000 classes Train:1,281,167 images Test: 50,000 images
  • Data format:jpeg Note: Data will be processed in src/dataset.py

Features

Mixed Precision

The mixed precision training method accelerates the deep learning neural network training process by using both the single-precision and half-precision data formats, and maintains the network precision achieved by the single-precision training at the same time. Mixed precision training can accelerate the computation process, reduce memory usage, and enable a larger model or batch size to be trained on specific hardware. For FP16 operators, if the input data type is FP32, the backend of MindSpore will automatically handle it with reduced precision. Users could check the reduced-precision operators by enabling INFO log and then searching ‘reduce precision’.

Environment Requirements

Script Description

├── model_zoo
    ├── README.md        #readme file
    ├── biggan
        ├── ascend310_infer        #for ascend310 model infer
        │   ├── build.sh           #for env build
        │   ├── CMakeLists.txt
        │   ├── inc
        │   │   └── utils.h        #necessary header file
        │   └── src
        │       ├── main.cc        #model infer main .c
        │       └── utils.cc
        ├── export.py             #for model infer export mindir
        ├── model
        │   ├── BigGAN.py        #model def file
        │   ├── __init__.py
        │   ├── layers.py        #model layer file
        │   └── losses.py        #model loss def file
        ├── postprocess.py       #for model infer postprocess
        ├── preprocess.py        #for model infer preprocess
        ├── scripts
        │   ├── run_infer_310.sh        #model infer script
        │   ├── train_1p.sh             #model train 1p shell script
        │   ├── train_8p.sh             #model train 8p shell script
        ├── src
        │   ├── calculate_inception_moments.py          #for model train measurable cal
        │   ├── datasets.py                             #for model dataset
        │   ├── inception_utils.py                      #model necessary file
        │   ├── inception_v3.py                         #inception_v3 def file
        │   ├── __init__.py
        │   └── utils.py                                #model utils file
        └── train.py                                    #model train file

Model Train

1、training model on 1 device
bash ./scripts/run_standalone_train_ascend.sh 'DEVICE_ID' 'DATASET_PATH'
exp: bash ./scripts/run_standalone_train_ascend.sh '0' '/dataset/imagenet'

2、training model on multi device
bash ./scripts/run_distribute_train_ascend.sh 'DATASET_PATH'
exp:bash ./scripts/run_distribute_train_ascend.sh '/dataset/imagenet'

Note:hccl.json which is specified by RANK_TABLE_FILE is needed when you are running a distribute task. You can generate it by using the [hccl_tools](Note:hccl.json which is specified by RANK_TABLE_FILE is needed when you are running a distribute task. You can generate it by using the hccl_tools.).

Model Eval

bash ./scripts/run_eval.sh 'INPUT_PATH' 'OUTPUT_PATH' 'USED_CKPT' DEVICE_ID
exp: bash ./scripts/run_eval.sh 'test.jpg' './save_img' './G.ckpt' 0

Model Infer

Model Export

trans .ckpt to .mindir

python export.py --use_device 0 --ckpt_pth 'CKPT_PATH'
exp:python export.py --use_device 0 --ckpt_pth './weights/biggan.ckpt'

Run Infer

bash ./scripts/run_infer_310.sh 'MINDIR_PATH'  'DATA_PATH'
exp:bash ./scripts/run_infer_310.sh 'biggan.mindir' '/imagenet/eval'

Model Description

Parameters Ascend GPU
Model Version BigGAN BigGAN
Resource Ascend 910; CPU 2.60GHz, 192cores; Memory 755G; OS Euler2.8 NV SMX2 V100-32G
uploaded Date 07/25/2022 (month/day/year) 07/25/2022 (month/day/year)
MindSpore Version 1.6.0 1.6.0
Dataset ImageNet ImageNet
Training Parameters epoch=100, batch_size = 256, lr=0.01 epoch=100, batch_size=256, lr=0.01
Optimizer Adam Adam
Loss Function Binary CrossEntropy Loss Binary CrossEntropy Loss
outputs probability probobility
Loss G:0.22/D:0.98 G:0.23/D:1.01
Speed 1pc: 30 s/iter; 8pcs: 42 s/iter 1pc: 35 s/iter; 8pcs: 50 s/iter
Checkpoint for Fine tuning 513.5M (.ckpt file) 513.5M (.ckpt file)
Model for inference 513M(.mindir file) /

Description of Random Situation

In config file, we set the seed ,We also use random seed in train.py.

Model_Zoo Homepage

Please check the official homepage.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published