From 7bba9f8d112044fdf2d0ee12aa2ee73fe296ca48 Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Thu, 17 Dec 2020 17:41:38 +0800 Subject: [PATCH] Fix import error (#127) * fix some bug --- ppgan/datasets/transforms/__init__.py | 1 + ppgan/models/criterions/perceptual_loss.py | 2 +- ppgan/utils/download.py | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 ppgan/datasets/transforms/__init__.py diff --git a/ppgan/datasets/transforms/__init__.py b/ppgan/datasets/transforms/__init__.py new file mode 100644 index 0000000..3b0e160 --- /dev/null +++ b/ppgan/datasets/transforms/__init__.py @@ -0,0 +1 @@ +from .transforms import ResizeToScale, PairedRandomCrop, PairedRandomHorizontalFlip, Add \ No newline at end of file diff --git a/ppgan/models/criterions/perceptual_loss.py b/ppgan/models/criterions/perceptual_loss.py index f112b9f..2c57edc 100644 --- a/ppgan/models/criterions/perceptual_loss.py +++ b/ppgan/models/criterions/perceptual_loss.py @@ -29,7 +29,7 @@ class PerceptualVGG(nn.Layer): layer_name_list, vgg_type='vgg19', use_input_norm=True, - pretrained_url='https://paddlegan.bj.bcebos.com/model/vgg19.pdparams' + pretrained_url='https://paddlegan.bj.bcebos.com/models/vgg19.pdparams' ): super(PerceptualVGG, self).__init__() diff --git a/ppgan/utils/download.py b/ppgan/utils/download.py index e9411a2..0163584 100644 --- a/ppgan/utils/download.py +++ b/ppgan/utils/download.py @@ -18,20 +18,17 @@ from __future__ import print_function import os import sys -import os.path as osp +import time import shutil -import requests import hashlib import tarfile import zipfile -import time +import requests +import os.path as osp from tqdm import tqdm -import logging from .logger import get_logger -logger = get_logger('ppgan') - PPGAN_HOME = os.path.expanduser("~/.cache/ppgan/") DOWNLOAD_RETRY_LIMIT = 3 @@ -75,6 +72,7 @@ def get_path_from_url(url, md5sum=None, check_exist=True): fullpath = _map_path(url, root_dir) if osp.exists(fullpath) and check_exist and _md5check(fullpath, md5sum): + logger = get_logger('ppgan') logger.info("Found {}".format(fullpath)) else: if ParallelEnv().local_rank == 0: @@ -111,6 +109,7 @@ def _download(url, path, md5sum=None): raise RuntimeError("Download from {} failed. " "Retry limit reached".format(url)) + logger = get_logger('ppgan') logger.info("Downloading {} from {} to {}".format(fname, url, fullname)) req = requests.get(url, stream=True) @@ -141,6 +140,7 @@ def _md5check(fullname, md5sum=None): if md5sum is None: return True + logger = get_logger('ppgan') logger.info("File {} md5 checking...".format(fullname)) md5 = hashlib.md5() with open(fullname, 'rb') as f: @@ -159,6 +159,8 @@ def _decompress(fname): """ Decompress for zip and tar file """ + logger = get_logger('ppgan') + logger.info("Decompressing {}...".format(fname)) # For protecting decompressing interupted, -- GitLab