Exemple #1
0
device = get_device()

vgg = Vgg16().to(device)

fails = []

for s in STYLES:
    for c in CONTENT:
        item_name = f'{s}__{c}'
        item_dir = exp.make_item_dir(item_name)
        content = exp.load_content(c, 512, item_dir)
        style = exp.load_style(s, 512, item_dir)

        without_edge = perform_transfer(vgg,
                                        content,
                                        style,
                                        1e8,
                                        device=device,
                                        init='cpn')

        save_image(without_edge, item_dir / 'noedge.jpg')

        for ew in EDGE_WEIGHT:
            try:
                with_edge = perform_transfer(vgg,
                                             content,
                                             style,
                                             STYLE_WEIGHT,
                                             'qsobel',
                                             dict(q=EDGE_THRESHOLD),
                                             ew,
                                             device=device,
Exemple #2
0
fails = []

for s, c in STYLE_CONTENT_PAIRS:
    item_name = f'{s}__{c}'

    if (exp.results_dir / item_name).exists():
        continue

    item_dir = exp.make_item_dir(item_name)
    content = exp.load_content(c, 512, item_dir)
    style = exp.load_style(s, 512, item_dir)

    without_edge = perform_transfer(
        vgg, content, style,
        1e8,
        device=device, init='cpn'
    )

    save_image(without_edge, item_dir / 'noedge.jpg')

    for lew in [50, 100, 200]:
        lapstyle_1 = perform_transfer(
                vgg, content, style,
                1e8,
                'atlap', dict(detector="lapstyle", normalize=False, reduction="mse"), lew,
                device=device
            )
        save_image(lapstyle_1, item_dir / f'lapstyle_e={lew:06d}.jpg')

    for ew in [50, 100, 200, 1000, 10000, 100_000]:
fails = []

for s in STYLES:
    for c in CONTENT:
        item_name = f'{s}__{c}'

        if (exp.results_dir / item_name).exists():
            continue

        item_dir = exp.make_item_dir(item_name)
        content = exp.load_content(c, 512, item_dir)
        style = exp.load_style(s, 512, item_dir)

        without_edge = perform_transfer(vgg,
                                        content,
                                        style,
                                        1e8,
                                        device=device,
                                        init='cpn')

        save_image(without_edge, item_dir / 'noedge.jpg')

        for ew in EDGE_WEIGHT:
            try:
                with_edge = perform_transfer(vgg,
                                             content,
                                             style,
                                             STYLE_WEIGHT,
                                             'lap',
                                             dict(),
                                             ew,
                                             device=device,
Exemple #4
0
        item_name = f'{s}__{c}'

        if (exp.results_dir / item_name).exists():
            continue

        item_dir = exp.make_item_dir(item_name)
        content = exp.load_content(c, 512, item_dir)
        style = exp.load_style(s, 512, item_dir)

        for ew in EDGE_WEIGHT:
            for sig in SIGMA:
                for et in EDGE_THRESHOLD:
                    name = f"w={ew:g}s={sig}t={et}.jpg"
                    try:
                        with_edge = perform_transfer(vgg,
                                                     content,
                                                     style,
                                                     STYLE_WEIGHT,
                                                     'qsobel',
                                                     dict(sigma=sig, q=et),
                                                     ew,
                                                     device=device,
                                                     init='cpn')
                        res_path = item_dir / name
                        save_image(with_edge, res_path)
                    except Exception as e:
                        print(e)
                        fails.append(item_name + "/" + name)

json.dump(fails, (exp.results_dir / 'fails.json').open('w'), indent=2)
Exemple #5
0
    item_name = f'{s}__{c}'

    if (exp.results_dir / item_name).exists():
        continue

    item_dir = exp.make_item_dir(item_name)
    content = exp.load_content(c, 512, item_dir)
    style = exp.load_style(s, 512, item_dir)

    for ew in [1e-1, 1e0, 5e0, 1e1]:
        with_scaling = perform_transfer(vgg,
                                        content,
                                        style,
                                        1e4,
                                        'atlap',
                                        dict(detector="sobel_gs",
                                             reduction="mse",
                                             mode="lum",
                                             norm_q=.9),
                                        ew,
                                        device=device,
                                        init='cpn')
        res_path = item_dir / f'sc_w={ew:g}.jpg'
        save_image(with_scaling, res_path)

    without_edge = perform_transfer(vgg,
                                    content,
                                    style,
                                    1e8,
                                    device=device,
                                    init='cpn')
Exemple #6
0
]

exp = ExperimentRun('scaling-1')

exp.dump_sources()

device = get_device()

vgg = Vgg16().to(device)

fails = []

for s, c in STYLE_CONTENT_PAIRS:
    item_name = f'{s}__{c}'

    if (exp.results_dir / item_name).exists():
        continue

    item_dir = exp.make_item_dir(item_name)
    content = exp.load_content(c, 512, item_dir)
    style = exp.load_style(s, 512, item_dir)

    for ew in [1e-1, 1e2, 1e3, 1e4]:
        with_scaling = perform_transfer(
            vgg, content, style,
            1e8,
            'atlap', dict(detector="sobel_qt", reduction="mse"), ew,
            device=device, init='cpn'
        )
        save_image(with_scaling, item_dir / f'scaled_{ew:g}.jpg')
Exemple #7
0
    item_name = f'{s}__{c}'

    if (exp.results_dir / item_name).exists():
        continue

    item_dir = exp.make_item_dir(item_name)
    content = exp.load_content(c, 512, item_dir)
    style = exp.load_style(s, 512, item_dir)

    for ew in [1e-1, 1e0, 1e1, 1e2, 1e3, 1e4, 1e5]:
        lum = perform_transfer(vgg,
                               content,
                               style,
                               1e4,
                               'atlap',
                               dict(detector="sobel_gs",
                                    reduction="mse",
                                    normalize=False),
                               ew,
                               device=device,
                               init='cpn')
        save_image(lum, item_dir / f'lum_{ew:g}.jpg')

        mean = perform_transfer(vgg,
                                content,
                                style,
                                1e4,
                                'atlap',
                                dict(detector="sobel_gs",
                                     reduction="mse",
                                     normalize=False,
Exemple #8
0
device = get_device()

vgg = Vgg16().to(device)

fails = []

for s in STYLES:
    for c in CONTENT:
        item_name = f'{s}__{c}'
        item_dir = exp.make_item_dir(item_name)
        content = exp.load_content(c, 512, item_dir)
        style = exp.load_style(s, 512, item_dir)

        try:
            with_edge = perform_transfer(vgg,
                                         content,
                                         style,
                                         STYLE_WEIGHT,
                                         'tsobel',
                                         dict(threshold=EDGE_THRESHOLD,
                                              normalize=False),
                                         EDGE_WEIGHT,
                                         device=device,
                                         init='cpn')
            save_image(with_edge, item_dir / 'edge_nonorm.jpg')
        except Exception as e:
            print(e)
            fails.append(item_name)

json.dump(fails, (exp.results_dir / 'fails.json').open('w'), indent=2)