From 39a4cf50ba7a7e7e0022b4d2f1e4ce35112d239f Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Fri, 26 Feb 2021 20:46:24 +0800 Subject: [PATCH] Fix bug of conditional gan and building wheels (#185) (#186) * fix bugs --- configs/cond_dcgan_mnist.yaml | 41 ++++++++++++++++--------- configs/pix2pix_facades.yaml | 3 ++ ppgan/apps/animegan_predictor.py | 2 +- ppgan/datasets/preprocess/transforms.py | 1 + setup.py | 5 +-- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/configs/cond_dcgan_mnist.yaml b/configs/cond_dcgan_mnist.yaml index 0c3aba1..e708396 100644 --- a/configs/cond_dcgan_mnist.yaml +++ b/configs/cond_dcgan_mnist.yaml @@ -18,46 +18,57 @@ model: norm_type: batch n_class: 10 use_sigmoid: True - gan_mode: vanilla + gan_criterion: + name: GANLoss + gan_mode: vanilla dataset: train: name: CommonVisionDataset - class_name: MNIST - dataroot: None + dataset_name: MNIST num_workers: 4 batch_size: 64 - mode: train - return_cls: True + return_label: True transforms: - name: Normalize mean: [127.5] std: [127.5] keys: [image] + params: + mode: train test: name: CommonVisionDataset - class_name: MNIST - dataroot: None + dataset_name: MNIST num_workers: 0 batch_size: 64 - mode: test + return_label: True + params: + mode: train transforms: - name: Normalize mean: [127.5] std: [127.5] keys: [image] - return_cls: True - - -optimizer: - name: Adam - beta1: 0.5 lr_scheduler: - name: linear + name: LinearDecay learning_rate: 0.0002 start_epoch: 100 decay_epochs: 100 + # will get from real dataset + iters_per_epoch: 1 + +optimizer: + optimizer_G: + name: Adam + net_names: + - netG + beta1: 0.5 + optimizer_D: + name: Adam + net_names: + - netD + beta1: 0.5 log_config: interval: 100 diff --git a/configs/pix2pix_facades.yaml b/configs/pix2pix_facades.yaml index 0123bf9..b73005d 100644 --- a/configs/pix2pix_facades.yaml +++ b/configs/pix2pix_facades.yaml @@ -64,6 +64,9 @@ dataset: preprocess: - name: LoadImageFromFile key: pair + - name: SplitPairedImage + key: pair + paired_keys: [A, B] - name: Transforms input_keys: [A, B] pipeline: diff --git a/ppgan/apps/animegan_predictor.py b/ppgan/apps/animegan_predictor.py index 8c5655d..b3c8b0b 100644 --- a/ppgan/apps/animegan_predictor.py +++ b/ppgan/apps/animegan_predictor.py @@ -18,7 +18,7 @@ import cv2 import paddle from .base_predictor import BasePredictor -from ppgan.datasets.transforms import ResizeToScale +from ppgan.datasets.preprocess.transforms import ResizeToScale import paddle.vision.transforms as T from ppgan.models.generators import AnimeGenerator from ppgan.utils.download import get_path_from_url diff --git a/ppgan/datasets/preprocess/transforms.py b/ppgan/datasets/preprocess/transforms.py index 73481e8..ab378c2 100644 --- a/ppgan/datasets/preprocess/transforms.py +++ b/ppgan/datasets/preprocess/transforms.py @@ -41,6 +41,7 @@ TRANSFORMS.register(T.RandomHorizontalFlip) TRANSFORMS.register(T.RandomVerticalFlip) TRANSFORMS.register(T.Normalize) TRANSFORMS.register(T.Transpose) +TRANSFORMS.register(T.Grayscale) @PREPROCESS.register() diff --git a/setup.py b/setup.py index ff5d222..44c31d1 100644 --- a/setup.py +++ b/setup.py @@ -13,6 +13,7 @@ # limitations under the License. from setuptools import setup +from setuptools import find_packages from io import open with open('requirements.txt', encoding="utf-8-sig") as f: @@ -27,11 +28,11 @@ def readme(): setup( name='ppgan', - packages=['ppgan'], + packages=find_packages(), include_package_data=True, entry_points={"console_scripts": ["paddlegan= paddlegan.paddlegan:main"]}, author='PaddlePaddle Author', - version='0.1.0', + version='2.0.0-beta', install_requires=requirements, license='Apache License 2.0', description='Awesome GAN toolkits based on PaddlePaddle', -- GitLab