Exemple #1
0
    '080480.jpg',
    '039459.jpg',
    '153323.jpg',
    '011793.jpg',
    '156817.jpg',
    '121050.jpg',
    '198603.jpg',
    '041897.jpg',
    '131899.jpg',
    '048286.jpg',
    '179577.jpg',
    '024184.jpg',
    '016530.jpg',
]

download.from_google_drive("0B7EVK8r0v71pZjFTYXZWM3FlRnM")


def center_crop(x, crop_h=128, crop_w=None, resize_w=64):
    # crop the images to [crop_h,crop_w,3] then resize to [resize_h,resize_w,3]
    if crop_w is None:
        crop_w = crop_h  # the width and height after cropped
    h, w = x.shape[:2]
    j = int(round((h - crop_h) / 2.)) + 15
    i = int(round((w - crop_w) / 2.))
    im = Image.fromarray(x[j:j + crop_h, i:i + crop_w])
    return np.array(im.resize([resize_w, resize_w]))


archive = zipfile.ZipFile('img_align_celeba.zip', 'r')
Exemple #2
0
from dataloader import *

from checkpointer import Checkpointer

from dlutils.pytorch import count_parameters
from dlutils import download
from defaults import get_cfg_defaults
from tqdm import tqdm

from PIL import Image
from matplotlib import pyplot as plt
import utils

dnnlib.tflib.init_tf()

download.from_google_drive('1CIDc9i070KQhHlkr4yIwoJC8xqrwjE0_',
                           directory="metrics")


def downscale(images):
    if images.shape[2] > 256:
        factor = images.shape[2] // 256
        images = torch.reshape(images, [
            -1, images.shape[1], images.shape[2] // factor, factor,
            images.shape[3] // factor, factor
        ])
        images = torch.mean(images, dim=(3, 5))
    images = np.clip((images.cpu().numpy() + 1.0) * 127, 0,
                     255).astype(np.uint8)
    return images

Exemple #3
0
    '080480.jpg',
    '039459.jpg',
    '153323.jpg',
    '011793.jpg',
    '156817.jpg',
    '121050.jpg',
    '198603.jpg',
    '041897.jpg',
    '131899.jpg',
    '048286.jpg',
    '179577.jpg',
    '024184.jpg',
    '016530.jpg',
]

download.from_google_drive("0B7EVK8r0v71pZjFTYXZWM3FlRnM", directory=directory)


def center_crop(x, crop_h=128, crop_w=None, resize_w=128):
    # crop the images to [crop_h,crop_w,3] then resize to [resize_h,resize_w,3]
    if crop_w is None:
        crop_w = crop_h  # the width and height after cropped
    h, w = x.shape[:2]
    j = int(round((h - crop_h) / 2.)) + 15
    i = int(round((w - crop_w) / 2.))
    return misc.imresize(x[j:j + crop_h, i:i + crop_w], [resize_w, resize_w])


archive = zipfile.ZipFile(os.path.join(directory, 'img_align_celeba.zip'), 'r')

names = archive.namelist()