diff --git a/applications/tools/ps_demo.py b/applications/tools/ps_demo.py index f8acb7d3c6b66beeb7d4a6914cf7161f4a5f2f9b..4e3ec9c359504768419deefa352c3f649bed1b84 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 6e8a7e9db2c17508d47f3092d5861ccc42aa2de9..ed269bf8e8e1e904d6e8c23f9b447ae498f7711d 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 fcfbbcaa3488f56915efb8be8ba4d244b2e13782..ff93aed2f37989ea21ab042c43e3791c89744a61 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 fe93c71e718faaff1c019db9fb6632509d3db4f1..93e9577b900a74448f0af194fa2b5719a87707b3 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 68c57e05516f2a39680dff0938de9e1ade900fd6..ac994ab0f69c04aad016a59134ed3d4a32b46d00 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 95e7658f99f9bd4e580a65b0e4c4a2e295430031..a9eec8aacc793e0ae325208774a9a82949028fdb 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 cf8ac8d3aedbf4ec70de74a15f8a4a766df8a6a8..56cdd9197352dd2639bbedccc14efb1d707fd714 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 2b0559008da8754d1b13298275c9f28bb31eb761..2c6be37c56d9ca59ff6c5dbda3f0b05b47cb04a4 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 b2b745461fe8cd8df802d4ad35661304d0e5e010..ef2c03b4f2cf33535408a272be1d95fad3d9eb1f 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 977d2657ce10b1b022bb3157d067616425fd7ef3..1a4fc8183cff26f1b37bc880d1c89f91d76f9425 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 befc18568797cccb0670da028407797c02f247ef..9cfb01ab0fbd286b05bc32eee90c66d1a9c672f2 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 57428989936f7bc7a537adef65e677cd4778cc11..3e9f23bd52bbf7ca14dbcaf0dbd8635c8d2b1bb5 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 8206b5ab461143d88ac733f02cc3ddf3676c2b97..ba2265a55db6efea7545ef4b0febb1894219a413 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 0459d635a018d7b5cbb034ad8947a9aafb7b8698..9d0c83a7224da7677ad7c087643bcedeb1c930e2 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 494099cdb46c920dc3181369f04dd6f03aa00329..53ffbbe2b34813c53f769b2a452862b071577426 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 b518c6ba85044ded0dc105d8d2c29f6a28d08d0a..0e91a8fdf8fc2bf1f8b6a0a1d65fc74d210e2d0b 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 59f58a197c9a86fdd345c0303ab0e0b826f4888a..0c5a2a8710cd92f4f805aa8ac271d8ec51e38a1c 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 b56699f32f682fbf38b04d2052e3f560c1a933f5..4853462a0cff780420d2577bbfa6e0c6e22c88cc 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 8f1fb87d786acf9eddc38ffb1430c219181e2b04..5be958af7949e0bcc2fc4795e13a0e28039d8e58 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 aed144f2746a7400ba3e4c540490fba5d148140b..f48f2ffc52f6ec3e6993a6015418ed86a70325f3 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 15c2e99dbf311d622e7e64d21954dfbed0e7369a..6babcde6f44939aacb919e4247dec1dc2fba1398 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 94e58e9f8791a3159b511b3b1b51f660ff5e0697..14b90b7f1b90a5b20cb6b89e4254863c05b4ea73 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 613ea1489387af0fdd5f160c4fb9276db6e83453..a61f7979b1a7758b622abda4f49c4eca24cdd8cf 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 3e1d013ed2dfcc75ec034e30c886a6f3c2619efd..da213d2586fc9da41b39fb5afb24af6da458cf6a 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 35a2866005f1df574a35a6b11a02c737445da81c..643d4766e4deb71a1b3d5c47a2777cfdc9b677a5 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 d81c2f64086b219f045a58d65463b0099a793aad..857304d1be40a82dedec190eadea4778ef5b43c8 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 65cfde310cc1e2b8149443cdd9c85330e278509e..d5c371cf67c107dc5385f919a4958a484b38ee40 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 36412a55104085154dc7dac3b7d923a369ceab07..027a051012c11bf309605fccdd19f80b75b5fb01 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 4954a2d3f1e9f4caa07ccd7620c65579d9995e18..9b7b4bc99c9f00c49684fa03e26420a9619f0b0a 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 c876f93de18a3a11b0946e65dc1f610d73bf7ec9..1c6f371833742fbd303e301d850c2204d50e8db4 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 b062a7bb97909d77e065aef44cb446fdb6f7717a..6ba9c07a9105effe603cc535745f6710325830f6 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 467336b409fd197432a3a8ada93a8520d3e8a498..09b0c652a414b073dadd651d3bb1582c509fccae 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 607f4e915f43eb85b0032981e70081ba03cb2a8c..6ed338ea6ecb7178e5068df50380494f23de14b3 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 a2ada1b323d1f19656e9f730889c613266015214..c981dbf6c92a0603059804904f12cdcf54619ef5 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 c1fe3e6a48a2c4a36bc1a1064f81178873fdbbbf..436724f6561d094f23ba1e9993a4be46c1f88d5b 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 6d91d956555d3185f02b395a7f2954e9914a1d0d..056730715f1e5bb23e5864fa52a9fe2c5626cb35 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 d6376e151eb102c8c2c3932c0149c912f7f73350..3349acdaf455f753e43dde5d4abfecf6ed87bc4d 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 4429d9891e133db9239545ce8916b9ec6a508f5f..6f6b433a35b579dfcce0e1760480eb2beac613af 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 4aa7f61ef5145ee859a99db962b055d025d34306..85604f0953ba5569b9f1d63f8fcaf1d152004e32 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 b806016a6f0412cc548b27eaa3149576042dc806..909ce38612c547a89829795a00d28091ea155535 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 0a7fe379f421314c8574054fec8c775bcdef609b..ba1bcd4819096a4f7eb77a036a897ddf7122e3a2 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 80113735cf3543eba14842a4ba4a4d243f3e736c..236f34058a7dd003a4cc82ef77e52bf0fcea0afa 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 1511b717677c3ecaa628224347515dca6f741c33..41a68fa58818ec67aa48e5531452a2b07b114b30 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 f81f1be47faab99854fb5104275eaf42282584fc..8de4bd07e05dd583f881fe1b2c8b62ea419d6765 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 9462055d32554d4a2991dc988e73a4a9366ba888..5e83e7116817c217908104d5f211a4f711d12584 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 a083eed491cf999981ead45a8a83868969beeb10..7381e149a8e104acab6fb392f7ea12fef18715a6 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 f731f8ba370e7ac5c185b0536b80aab7611f748c..38d294a686fe884951b4ff657ad790bc97874ce7 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 6a5bd6181b083a567a95cff43f66494a76ad1f19..7dd63f24a3120b66108f500231d47218a587c0b4 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 b8c15d5e13ae0f651942082f1572cc6a02072b07..1924d0df5d0c5446770d5e0a1f9d7c40d3e383d4 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 ffc7f585d7dc3fa05466ed78b29f044f4f00ffe2..80b31578871417008355d0c50d5e6d9820eff30c 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 2c6bc93634622f370e9e70590e8f83e387485b88..102ed9de790522bf4932c270368119d5e3cbbcae 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 32ca581f8fcaac86fe3bf1bfeaca7617ecc0e06a..0dc8a8820bd020369a7b5b36a5067429ea8fca9d 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 bb0cc66ada031ab0098c128d048d2356d9c80e2a..dce20e278f1aaacc70821c9d515666d64dd2d3bd 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 3e84d8a4669078f8a6cb0bffdb93fbd79df254ac..d38f38a2d3f261c9eff9dcb2813778b4671d7705 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 4e0a078ac771a2144da14874519ce1d6b3db3885..f781edd309002906d38838df30936b25dd74334e 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 54d6ff1452ba1a1d5914aea6e4e1aea7f5b0f21c..9d5a7688910992d4c05343a50413d248b7b78d53 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 65ba6ed9203d4fd7f39c8256dc6d11d1b4552c3b..f96e92cce68af2ddcd7efc02a7fac9767d2f3dfe 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 656bc77460211a6463ed1e69807409769a139009..2cc3e994f986330ccec65f2f576207f0ce5c48a4 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 e9d32d99fe84dabfa4f70c373a98a3f1c85b0803..57021870b340283a36eb3238bb42da598c3181e9 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 39b6389ebd3ea09186ee1d04e497a8bc27a3165b..e21943dfab43d66b8cd63c388cea2d8e8a553cd8 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 810cada4020f299f8611d2ddc7eb1d38c4bf7b50..389b0eb981a4400ff399d3756912a15d80ccb5fd 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 df3a0e71caab05f86cd6a6fa113c43f9b3308a34..414120a044f642529efb49db8ef198f576d8efcf 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 577280f96d1e72aff041b1771ca3c10df4c29af8..1c0e3e8ebb0d63e3e6e648c67a80e58c3121540b 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 98495b23f6bf1f12b4c464d87f3438f695b6ae04..43774dcc8c83d13cc2491c1064387f78a2880848 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 0ab24c046667dd25c66c4c5070cddabb1c73f638..cd12f62f823e0bf3e2fcc17d9579817260f73271 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 58d94f69e6a11be9dee35fbb16afbc298ae7e359..fed2acbac7f64137cd31a1b46a6f97a1b1f12599 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 dd953359c177b5fcd30b9ef0074d068715bb0796..cac42dadb8c566e76b12dab72cb837d1c4d5d4e6 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 a634cc66528b301832cb41d3127e0aad363ea433..79cd966b12bf40398ac6b92f723449b7925c1bb7 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 a6d2cc810dd3fa51f5a8f3eda5b07a55d95c26e9..d8cd1cecb56dd6b642d13965dc909c21ef1236ff 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 4c9d8b887e8290c4d0e4387886efc5bacff1b9dd..588260e2def485b5bdc1aaa2ab2b115ca8fad68d 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 838dc752aab5edbdbc7948456c0bb6a102d12952..fbe24015afacaf689d69e1d174aa7de17b8ec695 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 056e547e13bfc187b679293d0ec9bc406100e6ef..da8a8b7aacefa40a0942731b67a5c126eb0b447f 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 f6c46e2793ce19fca3aff5ef8535f4d89e851cd2..78cb0ad8ca4de2759d9983c263fa96192f12e99e 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 3d5adfc0d90f98274934ffe58c355ce8bb9f082d..004f9fa098a2fbdce7bb54d751dfe7d8a3ed3e9f 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 e1dac1f53a548135113bf48572324b7d7958982d..68edba4d128bae0d995a6b66d384da6a53e8c457 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.