From c4c00f5dbd022f383909905cb5408bfefa721495 Mon Sep 17 00:00:00 2001 From: ceci3 <592712189@qq.com> Date: Fri, 3 Jul 2020 12:39:50 +0000 Subject: [PATCH] update --- demo/gan_compression/configs/__init__.py | 3 +++ .../gan_compression/configs/resnet_configs.py | 2 ++ .../gan_compression/configs/single_configs.py | 3 +++ demo/gan_compression/distillers/__init__.py | 2 ++ demo/gan_compression/get_real_stat.py | 13 +++++++++++ demo/gan_compression/models/__init__.py | 2 ++ .../models/generator/mobile_generator.py | 13 +++++++++++ .../models/generator/resnet_generator.py | 13 +++++++++++ .../models/generator/sub_mobile_generator.py | 13 +++++++++++ .../models/generator/super_generator.py | 13 +++++++++++ demo/gan_compression/search.py | 13 +++++++++++ demo/gan_compression/select_arch.py | 2 ++ demo/gan_compression/supernets/__init__.py | 2 ++ demo/gan_compression/utils/image_pool.py | 22 ------------------- 14 files changed, 94 insertions(+), 22 deletions(-) diff --git a/demo/gan_compression/configs/__init__.py b/demo/gan_compression/configs/__init__.py index 3f1fd27b..7a939a03 100644 --- a/demo/gan_compression/configs/__init__.py +++ b/demo/gan_compression/configs/__init__.py @@ -1,3 +1,6 @@ +"""Based on https://github.com/mit-han-lab/gan-compression """ + + def encode_config(config): return '_'.join([str(c) for c in config['channels']]) diff --git a/demo/gan_compression/configs/resnet_configs.py b/demo/gan_compression/configs/resnet_configs.py index bcdcaf42..3082e2fb 100644 --- a/demo/gan_compression/configs/resnet_configs.py +++ b/demo/gan_compression/configs/resnet_configs.py @@ -1,3 +1,5 @@ +"""Based on https://github.com/mit-han-lab/gan-compression """ + import random diff --git a/demo/gan_compression/configs/single_configs.py b/demo/gan_compression/configs/single_configs.py index 3b3c292c..6132ffec 100644 --- a/demo/gan_compression/configs/single_configs.py +++ b/demo/gan_compression/configs/single_configs.py @@ -1,3 +1,6 @@ +"""Based on https://github.com/mit-han-lab/gan-compression """ + + class SingleConfigs: def __init__(self, config): self.attributes = ['n_channels'] diff --git a/demo/gan_compression/distillers/__init__.py b/demo/gan_compression/distillers/__init__.py index c4ea0256..01201838 100644 --- a/demo/gan_compression/distillers/__init__.py +++ b/demo/gan_compression/distillers/__init__.py @@ -1,3 +1,5 @@ +"""Based on https://github.com/mit-han-lab/gan-compression """ + import importlib from models.base_model import BaseModel diff --git a/demo/gan_compression/get_real_stat.py b/demo/gan_compression/get_real_stat.py index 53fee2d8..a291e905 100644 --- a/demo/gan_compression/get_real_stat.py +++ b/demo/gan_compression/get_real_stat.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. import numpy as np import argparse diff --git a/demo/gan_compression/models/__init__.py b/demo/gan_compression/models/__init__.py index d68f31fb..f4b0778e 100644 --- a/demo/gan_compression/models/__init__.py +++ b/demo/gan_compression/models/__init__.py @@ -1,3 +1,5 @@ +"""Based on https://github.com/mit-han-lab/gan-compression """ + import importlib from .base_model import BaseModel diff --git a/demo/gan_compression/models/generator/mobile_generator.py b/demo/gan_compression/models/generator/mobile_generator.py index 0c1c46df..dbe3e762 100644 --- a/demo/gan_compression/models/generator/mobile_generator.py +++ b/demo/gan_compression/models/generator/mobile_generator.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. import functools import paddle.fluid as fluid from paddle.fluid.dygraph.nn import InstanceNorm, Conv2D, Conv2DTranspose diff --git a/demo/gan_compression/models/generator/resnet_generator.py b/demo/gan_compression/models/generator/resnet_generator.py index c588c130..94135d44 100644 --- a/demo/gan_compression/models/generator/resnet_generator.py +++ b/demo/gan_compression/models/generator/resnet_generator.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. import functools import paddle.fluid as fluid import paddle.tensor as tensor diff --git a/demo/gan_compression/models/generator/sub_mobile_generator.py b/demo/gan_compression/models/generator/sub_mobile_generator.py index 7743b80e..5faef23a 100644 --- a/demo/gan_compression/models/generator/sub_mobile_generator.py +++ b/demo/gan_compression/models/generator/sub_mobile_generator.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. import functools import paddle.fluid as fluid import paddle.tensor as tensor diff --git a/demo/gan_compression/models/generator/super_generator.py b/demo/gan_compression/models/generator/super_generator.py index 6efe71b9..9861d234 100644 --- a/demo/gan_compression/models/generator/super_generator.py +++ b/demo/gan_compression/models/generator/super_generator.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. import functools import paddle.fluid as fluid import paddle.tensor as tensor diff --git a/demo/gan_compression/search.py b/demo/gan_compression/search.py index c5f0634e..9831dde7 100644 --- a/demo/gan_compression/search.py +++ b/demo/gan_compression/search.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. import os import pickle import random diff --git a/demo/gan_compression/select_arch.py b/demo/gan_compression/select_arch.py index aa06371a..b67be3f0 100644 --- a/demo/gan_compression/select_arch.py +++ b/demo/gan_compression/select_arch.py @@ -1,3 +1,5 @@ +"""Based on https://github.com/mit-han-lab/gan-compression """ + import argparse import pickle diff --git a/demo/gan_compression/supernets/__init__.py b/demo/gan_compression/supernets/__init__.py index e32da434..c7fdace3 100644 --- a/demo/gan_compression/supernets/__init__.py +++ b/demo/gan_compression/supernets/__init__.py @@ -1,3 +1,5 @@ +"""Based on https://github.com/mit-han-lab/gan-compression """ + import importlib from models.base_model import BaseModel diff --git a/demo/gan_compression/utils/image_pool.py b/demo/gan_compression/utils/image_pool.py index 17ad2226..8ec9904c 100644 --- a/demo/gan_compression/utils/image_pool.py +++ b/demo/gan_compression/utils/image_pool.py @@ -25,25 +25,3 @@ class ImagePool(): return temp else: return image - - -# return_images = [] -# for img in image: -# img = img.detach() -# img = fluid.layers.unsqueeze(img, axes=0) -# if self.num_imgs < self.pool_size: -# self.num_imgs = self.num_imgs + 1 -# self.images.append(img) -# return_images.append(img) -# else: -# p = random.uniform(0, 1) -# if p > 0.5: -# random_id = random.randint(0, self.pool_size - 1) -# temp = self.images[random_id] -# self.images[random_id] = img -# return_images.append(temp) -# else: -# return_images.append(img) -# -# return_images = fluid.layers.concat(return_images, axis=0) -# return return_images -- GitLab