From 9020cf3ce5c0dcb3497df77ee50c0e0541e094d2 Mon Sep 17 00:00:00 2001 From: qingqing01 Date: Thu, 29 Oct 2020 14:47:56 +0800 Subject: [PATCH] Add Copyright (#60) --- applications/tools/ps_demo.py | 2 +- ppgan/apps/__init__.py | 14 ++++++ ppgan/datasets/__init__.py | 2 +- ppgan/datasets/base_dataset.py | 16 ++++++- ppgan/datasets/builder.py | 34 +++++++++----- ppgan/datasets/image_folder.py | 44 +++++++++++++++---- ppgan/datasets/makeup_dataset.py | 2 +- ppgan/datasets/paired_dataset.py | 14 ++++++ ppgan/datasets/single_dataset.py | 14 ++++++ ppgan/datasets/sr_image_dataset.py | 22 ++++++++-- ppgan/datasets/transforms/__init__.py | 16 ++++++- ppgan/datasets/transforms/builder.py | 14 ++++++ .../datasets/transforms/makeup_transforms.py | 2 +- ppgan/datasets/transforms/transforms.py | 14 ++++++ ppgan/datasets/unpaired_dataset.py | 14 ++++++ ppgan/engine/trainer.py | 14 ++++++ ppgan/faceutils/__init__.py | 2 +- ppgan/faceutils/dlibutils/__init__.py | 14 ++++++ ppgan/faceutils/dlibutils/dlib_utils.py | 2 +- ppgan/faceutils/image.py | 14 ++++++ ppgan/faceutils/mask/__init__.py | 2 +- ppgan/faceutils/mask/face_parser.py | 14 ++++++ ppgan/faceutils/mask/model.py | 2 +- ppgan/metric/compute_fid.py | 39 ++++++++++------ ppgan/metric/inception.py | 2 +- ppgan/metric/metric_util.py | 20 ++++++++- ppgan/metric/psnr_ssim.py | 14 ++++++ ppgan/metric/test_fid_score.py | 17 ++++--- ppgan/models/__init__.py | 2 +- ppgan/models/backbones/__init__.py | 16 ++++++- ppgan/models/backbones/resnet_backbone.py | 14 ++++++ ppgan/models/base_model.py | 14 ++++++ ppgan/models/builder.py | 14 ++++++ ppgan/models/cycle_gan_model.py | 14 ++++++ ppgan/models/discriminators/__init__.py | 16 ++++++- ppgan/models/discriminators/builder.py | 15 ++++++- ppgan/models/discriminators/nlayers.py | 2 +- ppgan/models/generators/__init__.py | 2 +- ppgan/models/generators/builder.py | 15 ++++++- ppgan/models/generators/deoldify.py | 14 ++++++ ppgan/models/generators/hook.py | 14 ++++++ ppgan/models/generators/makeup.py | 2 +- ppgan/models/generators/occlusion_aware.py | 14 ++++++ ppgan/models/generators/remaster.py | 14 ++++++ ppgan/models/generators/resnet.py | 14 ++++++ ppgan/models/generators/rrdb_net.py | 14 ++++++ ppgan/models/generators/unet.py | 14 ++++++ ppgan/models/losses.py | 15 ++++++- ppgan/models/makeup_model.py | 2 +- ppgan/models/pix2pix_model.py | 14 ++++++ ppgan/models/sr_model.py | 14 ++++++ ppgan/models/srgan_model.py | 14 ++++++ ppgan/modules/dense_motion.py | 14 ++++++ ppgan/modules/first_order.py | 14 ++++++ ppgan/modules/init.py | 21 +++++++-- ppgan/modules/keypoint_detector.py | 14 ++++++ ppgan/modules/nn.py | 2 +- ppgan/modules/norm.py | 14 ++++++ ppgan/solver/__init__.py | 16 ++++++- ppgan/solver/lr_scheduler.py | 14 ++++++ ppgan/solver/optimizer.py | 14 ++++++ ppgan/utils/animate.py | 14 ++++++ ppgan/utils/config.py | 13 +++--- ppgan/utils/filesystem.py | 14 ++++++ ppgan/utils/image_pool.py | 27 +++++++++--- ppgan/utils/logger.py | 14 ++++++ ppgan/utils/options.py | 2 +- ppgan/utils/preprocess.py | 2 +- ppgan/utils/registry.py | 25 +++++++++-- ppgan/utils/setup.py | 14 ++++++ ppgan/utils/timer.py | 2 +- ppgan/utils/video.py | 17 ++++++- ppgan/utils/visual.py | 18 +++++++- setup.py | 7 ++- tools/main.py | 2 +- 75 files changed, 859 insertions(+), 98 deletions(-) diff --git a/applications/tools/ps_demo.py b/applications/tools/ps_demo.py index f8acb7d..4e3ec9c 100644 --- a/applications/tools/ps_demo.py +++ b/applications/tools/ps_demo.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/apps/__init__.py b/ppgan/apps/__init__.py index 6e8a7e9..ed269bf 100644 --- a/ppgan/apps/__init__.py +++ b/ppgan/apps/__init__.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from .dain_predictor import DAINPredictor from .deepremaster_predictor import DeepRemasterPredictor from .deoldify_predictor import DeOldifyPredictor diff --git a/ppgan/datasets/__init__.py b/ppgan/datasets/__init__.py index fcfbbca..ff93aed 100644 --- a/ppgan/datasets/__init__.py +++ b/ppgan/datasets/__init__.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/datasets/base_dataset.py b/ppgan/datasets/base_dataset.py index fe93c71..93e9577 100644 --- a/ppgan/datasets/base_dataset.py +++ b/ppgan/datasets/base_dataset.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # code was heavily based on https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix import random import numpy as np @@ -98,5 +112,5 @@ def get_transform(cfg, transform_list += [ transforms.Normalize(cfg.normalize.mean, cfg.normalize.std) ] - + return transforms.Compose(transform_list) diff --git a/ppgan/datasets/builder.py b/ppgan/datasets/builder.py index 68c57e0..ac994ab 100644 --- a/ppgan/datasets/builder.py +++ b/ppgan/datasets/builder.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import time import paddle import numbers @@ -59,17 +73,15 @@ class DictDataLoader(): place = paddle.CUDAPlace(ParallelEnv().dev_id) \ if ParallelEnv().nranks > 1 else paddle.CUDAPlace(0) - sampler = DistributedBatchSampler( - self.dataset, - batch_size=batch_size, - shuffle=True if is_train else False, - drop_last=True if is_train else False) - - self.dataloader = paddle.io.DataLoader( - self.dataset, - batch_sampler=sampler, - places=place, - num_workers=num_workers) + sampler = DistributedBatchSampler(self.dataset, + batch_size=batch_size, + shuffle=True if is_train else False, + drop_last=True if is_train else False) + + self.dataloader = paddle.io.DataLoader(self.dataset, + batch_sampler=sampler, + places=place, + num_workers=num_workers) self.batch_size = batch_size diff --git a/ppgan/datasets/image_folder.py b/ppgan/datasets/image_folder.py index 95e7658..a9eec8a 100644 --- a/ppgan/datasets/image_folder.py +++ b/ppgan/datasets/image_folder.py @@ -1,3 +1,16 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """A modified image folder class We modify the official PyTorch image folder (https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py) @@ -10,9 +23,20 @@ import os import os.path IMG_EXTENSIONS = [ - '.jpg', '.JPG', '.jpeg', '.JPEG', - '.png', '.PNG', '.ppm', '.PPM', '.bmp', '.BMP', - '.tif', '.TIF', '.tiff', '.TIFF', + '.jpg', + '.JPG', + '.jpeg', + '.JPEG', + '.png', + '.PNG', + '.ppm', + '.PPM', + '.bmp', + '.BMP', + '.tif', + '.TIF', + '.tiff', + '.TIFF', ] @@ -29,7 +53,7 @@ def make_dataset(dir, max_dataset_size=float("inf")): if is_image_file(fname): path = os.path.join(root, fname) images.append(path) - + return images[:min(float(max_dataset_size), len(images))] @@ -38,14 +62,16 @@ def default_loader(path): class ImageFolder(Dataset): - - def __init__(self, root, transform=None, return_paths=False, + def __init__(self, + root, + transform=None, + return_paths=False, loader=default_loader): imgs = make_dataset(root) if len(imgs) == 0: - raise(RuntimeError("Found 0 images in: " + root + "\n" - "Supported image extensions are: " + - ",".join(IMG_EXTENSIONS))) + raise (RuntimeError("Found 0 images in: " + root + "\n" + "Supported image extensions are: " + + ",".join(IMG_EXTENSIONS))) self.root = root self.imgs = imgs diff --git a/ppgan/datasets/makeup_dataset.py b/ppgan/datasets/makeup_dataset.py index cf8ac8d..56cdd91 100644 --- a/ppgan/datasets/makeup_dataset.py +++ b/ppgan/datasets/makeup_dataset.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/datasets/paired_dataset.py b/ppgan/datasets/paired_dataset.py index 2b05590..2c6be37 100644 --- a/ppgan/datasets/paired_dataset.py +++ b/ppgan/datasets/paired_dataset.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import cv2 import paddle import os.path diff --git a/ppgan/datasets/single_dataset.py b/ppgan/datasets/single_dataset.py index b2b7454..ef2c03b 100644 --- a/ppgan/datasets/single_dataset.py +++ b/ppgan/datasets/single_dataset.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import cv2 import paddle from .base_dataset import BaseDataset, get_transform diff --git a/ppgan/datasets/sr_image_dataset.py b/ppgan/datasets/sr_image_dataset.py index 977d265..1a4fc81 100644 --- a/ppgan/datasets/sr_image_dataset.py +++ b/ppgan/datasets/sr_image_dataset.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # import mmcv import os import cv2 @@ -33,13 +47,15 @@ def scandir(dir_path, suffix=None, recursive=False): yield rel_path else: if recursive: - yield from _scandir( - entry.path, suffix=suffix, recursive=recursive) + yield from _scandir(entry.path, + suffix=suffix, + recursive=recursive) else: continue return _scandir(dir_path, suffix=suffix, recursive=recursive) + def paired_paths_from_folder(folders, keys, filename_tmpl): """Generate paired paths from folders. """ @@ -70,6 +86,7 @@ def paired_paths_from_folder(folders, keys, filename_tmpl): (f'{gt_key}_path', gt_path)])) return paths + def paired_random_crop(img_gts, img_lqs, gt_patch_size, scale, gt_path): """Paired random crop. @@ -180,7 +197,6 @@ def augment(imgs, hflip=True, rotation=True, flows=None): @DATASETS.register() class SRImageDataset(Dataset): """Paired image dataset for image restoration.""" - def __init__(self, cfg): super(SRImageDataset, self).__init__() self.cfg = cfg diff --git a/ppgan/datasets/transforms/__init__.py b/ppgan/datasets/transforms/__init__.py index befc185..9cfb01a 100644 --- a/ppgan/datasets/transforms/__init__.py +++ b/ppgan/datasets/transforms/__init__.py @@ -1 +1,15 @@ -from .transforms import PairedRandomCrop, PairedRandomHorizontalFlip +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .transforms import PairedRandomCrop, PairedRandomHorizontalFlip diff --git a/ppgan/datasets/transforms/builder.py b/ppgan/datasets/transforms/builder.py index 5742898..3e9f23b 100644 --- a/ppgan/datasets/transforms/builder.py +++ b/ppgan/datasets/transforms/builder.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import copy import traceback import paddle diff --git a/ppgan/datasets/transforms/makeup_transforms.py b/ppgan/datasets/transforms/makeup_transforms.py index 8206b5a..ba2265a 100644 --- a/ppgan/datasets/transforms/makeup_transforms.py +++ b/ppgan/datasets/transforms/makeup_transforms.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/datasets/transforms/transforms.py b/ppgan/datasets/transforms/transforms.py index 0459d63..9d0c83a 100644 --- a/ppgan/datasets/transforms/transforms.py +++ b/ppgan/datasets/transforms/transforms.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import sys import random import numbers diff --git a/ppgan/datasets/unpaired_dataset.py b/ppgan/datasets/unpaired_dataset.py index 494099c..53ffbbe 100644 --- a/ppgan/datasets/unpaired_dataset.py +++ b/ppgan/datasets/unpaired_dataset.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import cv2 import random import os.path diff --git a/ppgan/engine/trainer.py b/ppgan/engine/trainer.py index b518c6b..0e91a8f 100644 --- a/ppgan/engine/trainer.py +++ b/ppgan/engine/trainer.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import time import copy diff --git a/ppgan/faceutils/__init__.py b/ppgan/faceutils/__init__.py index 59f58a1..0c5a2a8 100644 --- a/ppgan/faceutils/__init__.py +++ b/ppgan/faceutils/__init__.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/faceutils/dlibutils/__init__.py b/ppgan/faceutils/dlibutils/__init__.py index b56699f..4853462 100644 --- a/ppgan/faceutils/dlibutils/__init__.py +++ b/ppgan/faceutils/dlibutils/__init__.py @@ -1 +1,15 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from .dlib_utils import detect, crop, landmarks, crop_from_array diff --git a/ppgan/faceutils/dlibutils/dlib_utils.py b/ppgan/faceutils/dlibutils/dlib_utils.py index 8f1fb87..5be958a 100644 --- a/ppgan/faceutils/dlibutils/dlib_utils.py +++ b/ppgan/faceutils/dlibutils/dlib_utils.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/faceutils/image.py b/ppgan/faceutils/image.py index aed144f..f48f2ff 100644 --- a/ppgan/faceutils/image.py +++ b/ppgan/faceutils/image.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import numpy as np import cv2 from io import BytesIO diff --git a/ppgan/faceutils/mask/__init__.py b/ppgan/faceutils/mask/__init__.py index 15c2e99..6babcde 100644 --- a/ppgan/faceutils/mask/__init__.py +++ b/ppgan/faceutils/mask/__init__.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/faceutils/mask/face_parser.py b/ppgan/faceutils/mask/face_parser.py index 94e58e9..14b90b7 100644 --- a/ppgan/faceutils/mask/face_parser.py +++ b/ppgan/faceutils/mask/face_parser.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os.path as osp import numpy as np diff --git a/ppgan/faceutils/mask/model.py b/ppgan/faceutils/mask/model.py index 613ea14..a61f797 100644 --- a/ppgan/faceutils/mask/model.py +++ b/ppgan/faceutils/mask/model.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/metric/compute_fid.py b/ppgan/metric/compute_fid.py index 3e1d013..da213d2 100644 --- a/ppgan/metric/compute_fid.py +++ b/ppgan/metric/compute_fid.py @@ -1,4 +1,4 @@ -#copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +#Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ from paddle.fluid.dygraph.base import to_variable try: from tqdm import tqdm except: + def tqdm(x): return x @@ -131,7 +132,13 @@ def calculate_fid_given_img(img_fake, return fid_value -def _get_activations(files, model, batch_size, dims, use_gpu, premodel_path, style=None): +def _get_activations(files, + model, + batch_size, + dims, + use_gpu, + premodel_path, + style=None): if len(files) % batch_size != 0: print(('Warning: number of images is not a multiple of the ' 'batch size. Some samples are going to be ignored.')) @@ -159,8 +166,7 @@ def _get_activations(files, model, batch_size, dims, use_gpu, premodel_path, sty img_list.append(np.array(im).astype('float32')) - images = np.array( - img_list) + images = np.array(img_list) else: images = np.array( [imread(str(f)).astype(np.float32) for f in files[start:end]]) @@ -179,7 +185,7 @@ def _get_activations(files, model, batch_size, dims, use_gpu, premodel_path, sty std = np.array([0.229, 0.224, 0.225]).astype('float32') images[:] = (images[:] - mean[:, None, None]) / std[:, None, None] - if style=='stargan': + if style == 'stargan': pred_arr[start:end] = inception_infer(images, premodel_path) else: with fluid.dygraph.guard(): @@ -197,10 +203,11 @@ def _get_activations(files, model, batch_size, dims, use_gpu, premodel_path, sty def inception_infer(x, model_path): exe = fluid.Executor() - [inference_program, feed_target_names, fetch_targets] = fluid.io.load_inference_model(model_path, exe) + [inference_program, feed_target_names, + fetch_targets] = fluid.io.load_inference_model(model_path, exe) results = exe.run(inference_program, - feed={feed_target_names[0]: x}, - fetch_list=fetch_targets) + feed={feed_target_names[0]: x}, + fetch_list=fetch_targets) return results[0] @@ -210,7 +217,7 @@ def _calculate_activation_statistics(files, batch_size=50, dims=2048, use_gpu=False, - style = None): + style=None): act = _get_activations(files, model, batch_size, dims, use_gpu, premodel_path, style) mu = np.mean(act, axis=0) @@ -218,8 +225,13 @@ def _calculate_activation_statistics(files, return mu, sigma -def _compute_statistics_of_path(path, model, batch_size, dims, use_gpu, - premodel_path, style=None): +def _compute_statistics_of_path(path, + model, + batch_size, + dims, + use_gpu, + premodel_path, + style=None): if path.endswith('.npz'): f = np.load(path) m, s = f['mu'][:], f['sigma'][:] @@ -231,7 +243,8 @@ def _compute_statistics_of_path(path, model, batch_size, dims, use_gpu, filenames, '*.jpg') or fnmatch.filter(filenames, '*.png'): files.append(os.path.join(root, filename)) m, s = _calculate_activation_statistics(files, model, premodel_path, - batch_size, dims, use_gpu, style) + batch_size, dims, use_gpu, + style) return m, s @@ -241,7 +254,7 @@ def calculate_fid_given_paths(paths, use_gpu, dims, model=None, - style = None): + style=None): assert os.path.exists( premodel_path ), 'pretrain_model path {} is not exists! Please download it first'.format( diff --git a/ppgan/metric/inception.py b/ppgan/metric/inception.py index 35a2866..643d476 100644 --- a/ppgan/metric/inception.py +++ b/ppgan/metric/inception.py @@ -1,4 +1,4 @@ -#copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +#Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. diff --git a/ppgan/metric/metric_util.py b/ppgan/metric/metric_util.py index d81c2f6..857304d 100644 --- a/ppgan/metric/metric_util.py +++ b/ppgan/metric/metric_util.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import numpy as np @@ -29,6 +43,7 @@ def reorder_image(img, input_order='HWC'): img = img.transpose(1, 2, 0) return img + def bgr2ycbcr(img, y_only=False): """Convert a BGR image to YCbCr image. @@ -52,16 +67,17 @@ def bgr2ycbcr(img, y_only=False): and range as input image. """ img_type = img.dtype - img = _convert_input_type_range(img) + #img = _convert_input_type_range(img) if y_only: out_img = np.dot(img, [24.966, 128.553, 65.481]) + 16.0 else: out_img = np.matmul( img, [[24.966, 112.0, -18.214], [128.553, -74.203, -93.786], [65.481, -37.797, 112.0]]) + [16, 128, 128] - out_img = _convert_output_type_range(out_img, img_type) + #out_img = _convert_output_type_range(out_img, img_type) return out_img + def to_y_channel(img): """Change to Y channel of YCbCr. diff --git a/ppgan/metric/psnr_ssim.py b/ppgan/metric/psnr_ssim.py index 65cfde3..d5c371c 100644 --- a/ppgan/metric/psnr_ssim.py +++ b/ppgan/metric/psnr_ssim.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import cv2 import numpy as np diff --git a/ppgan/metric/test_fid_score.py b/ppgan/metric/test_fid_score.py index 36412a5..027a051 100644 --- a/ppgan/metric/test_fid_score.py +++ b/ppgan/metric/test_fid_score.py @@ -1,4 +1,4 @@ -#copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +#Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. @@ -38,9 +38,10 @@ def parse_args(): type=int, default=1, help='sample number in a batch for inference.') - parser.add_argument('--style', - type=str, - help='calculation style: stargan or default (gan-compression style)') + parser.add_argument( + '--style', + type=str, + help='calculation style: stargan or default (gan-compression style)') args = parser.parse_args() return args @@ -53,8 +54,12 @@ def main(): inference_model_path = args.inference_model batch_size = args.batch_size - fid_value = calculate_fid_given_paths(paths, inference_model_path, - batch_size, args.use_gpu, 2048, style=args.style) + fid_value = calculate_fid_given_paths(paths, + inference_model_path, + batch_size, + args.use_gpu, + 2048, + style=args.style) print('FID: ', fid_value) diff --git a/ppgan/models/__init__.py b/ppgan/models/__init__.py index 4954a2d..9b7b4bc 100644 --- a/ppgan/models/__init__.py +++ b/ppgan/models/__init__.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/models/backbones/__init__.py b/ppgan/models/backbones/__init__.py index c876f93..1c6f371 100644 --- a/ppgan/models/backbones/__init__.py +++ b/ppgan/models/backbones/__init__.py @@ -1 +1,15 @@ -from .resnet_backbone import resnet18, resnet34, resnet50, resnet101, resnet152 \ No newline at end of file +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .resnet_backbone import resnet18, resnet34, resnet50, resnet101, resnet152 diff --git a/ppgan/models/backbones/resnet_backbone.py b/ppgan/models/backbones/resnet_backbone.py index b062a7b..6ba9c07 100644 --- a/ppgan/models/backbones/resnet_backbone.py +++ b/ppgan/models/backbones/resnet_backbone.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle import paddle.nn as nn diff --git a/ppgan/models/base_model.py b/ppgan/models/base_model.py index 467336b..09b0c65 100644 --- a/ppgan/models/base_model.py +++ b/ppgan/models/base_model.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # code was heavily based on https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix import os import paddle diff --git a/ppgan/models/builder.py b/ppgan/models/builder.py index 607f4e9..6ed338e 100644 --- a/ppgan/models/builder.py +++ b/ppgan/models/builder.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle from ..utils.registry import Registry diff --git a/ppgan/models/cycle_gan_model.py b/ppgan/models/cycle_gan_model.py index a2ada1b..c981dbf 100644 --- a/ppgan/models/cycle_gan_model.py +++ b/ppgan/models/cycle_gan_model.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle from .base_model import BaseModel diff --git a/ppgan/models/discriminators/__init__.py b/ppgan/models/discriminators/__init__.py index c1fe3e6..436724f 100644 --- a/ppgan/models/discriminators/__init__.py +++ b/ppgan/models/discriminators/__init__.py @@ -1 +1,15 @@ -from .nlayers import NLayerDiscriminator \ No newline at end of file +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .nlayers import NLayerDiscriminator diff --git a/ppgan/models/discriminators/builder.py b/ppgan/models/discriminators/builder.py index 6d91d95..0567307 100644 --- a/ppgan/models/discriminators/builder.py +++ b/ppgan/models/discriminators/builder.py @@ -1,7 +1,20 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import copy from ...utils.registry import Registry - DISCRIMINATORS = Registry("DISCRIMINATOR") diff --git a/ppgan/models/discriminators/nlayers.py b/ppgan/models/discriminators/nlayers.py index d6376e1..3349acd 100644 --- a/ppgan/models/discriminators/nlayers.py +++ b/ppgan/models/discriminators/nlayers.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/models/generators/__init__.py b/ppgan/models/generators/__init__.py index 4429d98..6f6b433 100644 --- a/ppgan/models/generators/__init__.py +++ b/ppgan/models/generators/__init__.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/models/generators/builder.py b/ppgan/models/generators/builder.py index 4aa7f61..85604f0 100644 --- a/ppgan/models/generators/builder.py +++ b/ppgan/models/generators/builder.py @@ -1,7 +1,20 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import copy from ...utils.registry import Registry - GENERATORS = Registry("GENERATOR") diff --git a/ppgan/models/generators/deoldify.py b/ppgan/models/generators/deoldify.py index b806016..909ce38 100644 --- a/ppgan/models/generators/deoldify.py +++ b/ppgan/models/generators/deoldify.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import numpy as np import paddle import paddle.nn as nn diff --git a/ppgan/models/generators/hook.py b/ppgan/models/generators/hook.py index 0a7fe37..ba1bcd4 100644 --- a/ppgan/models/generators/hook.py +++ b/ppgan/models/generators/hook.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import numpy as np import paddle diff --git a/ppgan/models/generators/makeup.py b/ppgan/models/generators/makeup.py index 8011373..236f340 100644 --- a/ppgan/models/generators/makeup.py +++ b/ppgan/models/generators/makeup.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/models/generators/occlusion_aware.py b/ppgan/models/generators/occlusion_aware.py index 1511b71..41a68fa 100644 --- a/ppgan/models/generators/occlusion_aware.py +++ b/ppgan/models/generators/occlusion_aware.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle from paddle import nn import paddle.nn.functional as F diff --git a/ppgan/models/generators/remaster.py b/ppgan/models/generators/remaster.py index f81f1be..8de4bd0 100644 --- a/ppgan/models/generators/remaster.py +++ b/ppgan/models/generators/remaster.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle import paddle.nn as nn import paddle.nn.functional as F diff --git a/ppgan/models/generators/resnet.py b/ppgan/models/generators/resnet.py index 9462055..5e83e71 100644 --- a/ppgan/models/generators/resnet.py +++ b/ppgan/models/generators/resnet.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle import paddle.nn as nn import functools diff --git a/ppgan/models/generators/rrdb_net.py b/ppgan/models/generators/rrdb_net.py index a083eed..7381e14 100644 --- a/ppgan/models/generators/rrdb_net.py +++ b/ppgan/models/generators/rrdb_net.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import functools import paddle import paddle.nn as nn diff --git a/ppgan/models/generators/unet.py b/ppgan/models/generators/unet.py index f731f8b..38d294a 100644 --- a/ppgan/models/generators/unet.py +++ b/ppgan/models/generators/unet.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import functools import paddle import paddle.nn as nn diff --git a/ppgan/models/losses.py b/ppgan/models/losses.py index 6a5bd61..7dd63f2 100644 --- a/ppgan/models/losses.py +++ b/ppgan/models/losses.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import numpy as np import paddle @@ -10,7 +24,6 @@ class GANLoss(nn.Layer): The GANLoss class abstracts away the need to create the target label tensor that has the same size as the input. """ - def __init__(self, gan_mode, target_real_label=1.0, target_fake_label=0.0): """ Initialize the GANLoss class. diff --git a/ppgan/models/makeup_model.py b/ppgan/models/makeup_model.py index b8c15d5..1924d0d 100644 --- a/ppgan/models/makeup_model.py +++ b/ppgan/models/makeup_model.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/models/pix2pix_model.py b/ppgan/models/pix2pix_model.py index ffc7f58..80b3157 100644 --- a/ppgan/models/pix2pix_model.py +++ b/ppgan/models/pix2pix_model.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle from .base_model import BaseModel diff --git a/ppgan/models/sr_model.py b/ppgan/models/sr_model.py index 2c6bc93..102ed9d 100644 --- a/ppgan/models/sr_model.py +++ b/ppgan/models/sr_model.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from collections import OrderedDict import paddle import paddle.nn as nn diff --git a/ppgan/models/srgan_model.py b/ppgan/models/srgan_model.py index 32ca581..0dc8a88 100644 --- a/ppgan/models/srgan_model.py +++ b/ppgan/models/srgan_model.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from collections import OrderedDict import paddle import paddle.nn as nn diff --git a/ppgan/modules/dense_motion.py b/ppgan/modules/dense_motion.py index bb0cc66..dce20e2 100644 --- a/ppgan/modules/dense_motion.py +++ b/ppgan/modules/dense_motion.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle import paddle.nn as nn import paddle.nn.functional as F diff --git a/ppgan/modules/first_order.py b/ppgan/modules/first_order.py index 3e84d8a..d38f38a 100644 --- a/ppgan/modules/first_order.py +++ b/ppgan/modules/first_order.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle import paddle.nn as nn import paddle.nn.functional as F diff --git a/ppgan/modules/init.py b/ppgan/modules/init.py index 4e0a078..f781edd 100644 --- a/ppgan/modules/init.py +++ b/ppgan/modules/init.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import math import numpy as np @@ -256,8 +270,10 @@ def kaiming_init(layer, distribution='normal'): assert distribution in ['uniform', 'normal'] if distribution == 'uniform': - kaiming_uniform_( - layer.weight, a=a, mode=mode, nonlinearity=nonlinearity) + kaiming_uniform_(layer.weight, + a=a, + mode=mode, + nonlinearity=nonlinearity) else: kaiming_normal_(layer.weight, a=a, mode=mode, nonlinearity=nonlinearity) if hasattr(layer, 'bias') and layer.bias is not None: @@ -273,7 +289,6 @@ def init_weights(net, init_type='normal', init_gain=0.02): We use 'normal' in the original pix2pix and CycleGAN paper. But xavier and kaiming might work better for some applications. Feel free to try yourself. """ - def init_func(m): # define the initialization function classname = m.__class__.__name__ if hasattr(m, 'weight') and (classname.find('Conv') != -1 diff --git a/ppgan/modules/keypoint_detector.py b/ppgan/modules/keypoint_detector.py index 54d6ff1..9d5a768 100644 --- a/ppgan/modules/keypoint_detector.py +++ b/ppgan/modules/keypoint_detector.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle import paddle.nn as nn import paddle.nn.functional as F diff --git a/ppgan/modules/nn.py b/ppgan/modules/nn.py index 65ba6ed..f96e92c 100644 --- a/ppgan/modules/nn.py +++ b/ppgan/modules/nn.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/modules/norm.py b/ppgan/modules/norm.py index 656bc77..2cc3e99 100644 --- a/ppgan/modules/norm.py +++ b/ppgan/modules/norm.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle import functools import paddle.nn as nn diff --git a/ppgan/solver/__init__.py b/ppgan/solver/__init__.py index e9d32d9..5702187 100644 --- a/ppgan/solver/__init__.py +++ b/ppgan/solver/__init__.py @@ -1 +1,15 @@ -from .optimizer import build_optimizer \ No newline at end of file +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .optimizer import build_optimizer diff --git a/ppgan/solver/lr_scheduler.py b/ppgan/solver/lr_scheduler.py index 39b6389..e21943d 100644 --- a/ppgan/solver/lr_scheduler.py +++ b/ppgan/solver/lr_scheduler.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import paddle diff --git a/ppgan/solver/optimizer.py b/ppgan/solver/optimizer.py index 810cada..389b0eb 100644 --- a/ppgan/solver/optimizer.py +++ b/ppgan/solver/optimizer.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import copy import paddle diff --git a/ppgan/utils/animate.py b/ppgan/utils/animate.py index df3a0e7..414120a 100644 --- a/ppgan/utils/animate.py +++ b/ppgan/utils/animate.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import numpy as np from scipy.spatial import ConvexHull diff --git a/ppgan/utils/config.py b/ppgan/utils/config.py index 577280f..1c0e3e8 100644 --- a/ppgan/utils/config.py +++ b/ppgan/utils/config.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ import os import yaml - __all__ = ['get_config'] @@ -65,7 +64,6 @@ def override(dl, ks, v): ks(list): list of keys v(str): value to be replaced """ - def str2num(v): try: return eval(v) @@ -104,8 +102,8 @@ def override_config(config, options=None): """ if options is not None: for opt in options: - assert isinstance(opt, str), ( - "option({}) should be a str".format(opt)) + assert isinstance(opt, + str), ("option({}) should be a str".format(opt)) assert "=" in opt, ( "option({}) should contain a =" "to distinguish between key and value".format(opt)) @@ -122,9 +120,8 @@ def get_config(fname, overrides=None, show=True): """ Read config from file """ - assert os.path.exists(fname), ( - 'config file({}) is not exist'.format(fname)) + assert os.path.exists(fname), ('config file({}) is not exist'.format(fname)) config = parse_config(fname) override_config(config, overrides) - return config \ No newline at end of file + return config diff --git a/ppgan/utils/filesystem.py b/ppgan/utils/filesystem.py index 98495b2..43774dc 100644 --- a/ppgan/utils/filesystem.py +++ b/ppgan/utils/filesystem.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import six import pickle diff --git a/ppgan/utils/image_pool.py b/ppgan/utils/image_pool.py index 0ab24c0..cd12f62 100644 --- a/ppgan/utils/image_pool.py +++ b/ppgan/utils/image_pool.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import random import paddle @@ -8,7 +22,6 @@ class ImagePool(): This buffer enables us to update discriminators using a history of generated images rather than the ones produced by the latest generators. """ - def __init__(self, pool_size): """Initialize the ImagePool class @@ -37,20 +50,22 @@ class ImagePool(): return_images = [] for image in images: image = paddle.unsqueeze(image, 0) - if self.num_imgs < self.pool_size: # if the buffer is not full; keep inserting current images to the buffer + if self.num_imgs < self.pool_size: # if the buffer is not full; keep inserting current images to the buffer self.num_imgs = self.num_imgs + 1 self.images.append(image) return_images.append(image) else: p = random.uniform(0, 1) if p > 0.5: # by 50% chance, the buffer will return a previously stored image, and insert the current image into the buffer - random_id = random.randint(0, self.pool_size - 1) # randint is inclusive + random_id = random.randint(0, self.pool_size - + 1) # randint is inclusive # FIXME: clone # tmp = (self.images[random_id]).detach() #.clone() - tmp = self.images[random_id] #.clone() + tmp = self.images[random_id] #.clone() self.images[random_id] = image return_images.append(tmp) - else: # by another 50% chance, the buffer will return the current image + else: # by another 50% chance, the buffer will return the current image return_images.append(image) - return_images = paddle.concat(return_images, 0) # collect all the images and return + return_images = paddle.concat(return_images, + 0) # collect all the images and return return return_images diff --git a/ppgan/utils/logger.py b/ppgan/utils/logger.py index 58d94f6..fed2acb 100644 --- a/ppgan/utils/logger.py +++ b/ppgan/utils/logger.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import logging import os import sys diff --git a/ppgan/utils/options.py b/ppgan/utils/options.py index dd95335..cac42da 100644 --- a/ppgan/utils/options.py +++ b/ppgan/utils/options.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/utils/preprocess.py b/ppgan/utils/preprocess.py index a634cc6..79cd966 100644 --- a/ppgan/utils/preprocess.py +++ b/ppgan/utils/preprocess.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/utils/registry.py b/ppgan/utils/registry.py index a6d2cc8..d8cd1ce 100644 --- a/ppgan/utils/registry.py +++ b/ppgan/utils/registry.py @@ -1,3 +1,18 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + class Registry(object): """ The registry that provides name -> object mapping, to support third-party users' custom modules. @@ -13,7 +28,6 @@ class Registry(object): .. code-block:: python BACKBONE_REGISTRY.register(MyBackbone) """ - def __init__(self, name): """ Args: @@ -26,7 +40,8 @@ class Registry(object): def _do_register(self, name, obj): assert ( name not in self._obj_map - ), "An object named '{}' was already registered in '{}' registry!".format(name, self._name) + ), "An object named '{}' was already registered in '{}' registry!".format( + name, self._name) self._obj_map[name] = obj def register(self, obj=None, name=None): @@ -52,6 +67,8 @@ class Registry(object): def get(self, name): ret = self._obj_map.get(name) if ret is None: - raise KeyError("No object named '{}' found in '{}' registry!".format(name, self._name)) + raise KeyError( + "No object named '{}' found in '{}' registry!".format( + name, self._name)) - return ret \ No newline at end of file + return ret diff --git a/ppgan/utils/setup.py b/ppgan/utils/setup.py index 4c9d8b8..588260e 100644 --- a/ppgan/utils/setup.py +++ b/ppgan/utils/setup.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import time import paddle diff --git a/ppgan/utils/timer.py b/ppgan/utils/timer.py index 838dc75..fbe2401 100644 --- a/ppgan/utils/timer.py +++ b/ppgan/utils/timer.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ppgan/utils/video.py b/ppgan/utils/video.py index 056e547..da8a8b7 100644 --- a/ppgan/utils/video.py +++ b/ppgan/utils/video.py @@ -1,6 +1,21 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import sys + def video2frames(video_path, outpath, **kargs): def _dict2str(kargs): cmd_str = '' @@ -41,4 +56,4 @@ def frames2video(frame_path, video_path, r): if os.system(cmd) != 0: raise RuntimeError('ffmpeg process video: {} error'.format(video_path)) - sys.stdout.flush() \ No newline at end of file + sys.stdout.flush() diff --git a/ppgan/utils/visual.py b/ppgan/utils/visual.py index f6c46e2..78cb0ad 100644 --- a/ppgan/utils/visual.py +++ b/ppgan/utils/visual.py @@ -1,3 +1,17 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import numpy as np from PIL import Image @@ -17,7 +31,9 @@ def tensor2img(input_image, min_max=(-1., 1.), imtype=np.uint8): image_numpy = np.tile(image_numpy, (3, 1, 1)) image_numpy = image_numpy.clip(min_max[0], min_max[1]) image_numpy = (image_numpy - min_max[0]) / (min_max[1] - min_max[0]) - image_numpy = (np.transpose(image_numpy, (1, 2, 0))) * 255.0 # post-processing: tranpose and scaling + image_numpy = (np.transpose( + image_numpy, + (1, 2, 0))) * 255.0 # post-processing: tranpose and scaling else: # if it is a numpy array, do nothing image_numpy = input_image return image_numpy.astype(imtype) diff --git a/setup.py b/setup.py index 3d5adfc..004f9fa 100644 --- a/setup.py +++ b/setup.py @@ -36,9 +36,7 @@ setup( description='Awesome GAN toolkits based on PaddlePaddle', url='https://github.com/PaddlePaddle/PaddleGAN', download_url='https://github.com/PaddlePaddle/PaddleGAN.git', - keywords=[ - 'gan paddlegan' - ], + keywords=['gan paddlegan'], classifiers=[ 'Intended Audience :: Developers', 'Operating System :: OS Independent', 'Natural Language :: Chinese (Simplified)', @@ -46,4 +44,5 @@ setup( 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Topic :: Utilities' - ], ) \ No newline at end of file + ], +) diff --git a/tools/main.py b/tools/main.py index e1dac1f..68edba4 100644 --- a/tools/main.py +++ b/tools/main.py @@ -1,4 +1,4 @@ -# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -- GitLab