Exemple #1
0
def main(ctx, width, height, channels, seed, name, preset_name):
    generators.set_seed(seed)

    kwargs, preset_name = presets.load(preset_name)

    print(preset_name)

    kwargs["shape"] = [height, width, channels]

    # print(kwargs)

    if "freq" not in kwargs:
        kwargs["freq"] = 3

    if "octaves" not in kwargs:
        kwargs["octaves"] = 1

    if "ridges" not in kwargs:
        kwargs["ridges"] = False

    tensor = generators.multires(**kwargs)

    tensor = recipes.post_process(tensor, **kwargs)

    with tf.Session().as_default():
        save(tensor, name)
Exemple #2
0
def main(ctx, seed, name, preset_name, input_filename):
    generators.set_seed(seed)

    tensor = tf.image.convert_image_dtype(load(input_filename), tf.float32)

    max_height = 1024
    max_width = 1024

    with tf.Session().as_default():
        height, width, channels = tf.shape(tensor).eval()

        need_resample = False

        # Some presets only like square images. Work around for now by cropping.
        if height != width:
            length = min(height, width)
            height = length
            width = length

            tensor = tf.image.resize_image_with_crop_or_pad(tensor, length, length)

        if height > max_height:
            need_resample = True
            width = int(width * (max_height / height))
            height = max_height

        if width > max_width:
            need_resample = True
            height = int(height * (max_width / width))
            width = max_width

        shape = [height, width, channels]

        if need_resample:
            tensor = effects.resample(tensor, shape)

        kwargs, preset_name = presets.load(preset_name, presets.EFFECTS_PRESETS())

        kwargs["shape"] = [height, width, channels]

        if "freq" not in kwargs:
            kwargs["freq"] = [3, 3]

        if "octaves" not in kwargs:
            kwargs["octaves"] = 1

        if "ridges" not in kwargs:
            kwargs["ridges"] = False

        tensor = effects.post_process(tensor, **kwargs)
        tensor = recipes.post_process(tensor, **kwargs)

        print(preset_name)
        save(tensor, name)
Exemple #3
0
def main(ctx, seed, name, no_resize, overrides, time, preset_name, input_filename):
    presets.bake_presets(seed)

    input_shape = effects.shape_from_file(input_filename)

    input_shape[2] = min(input_shape[2], 3)

    tensor = tf.image.convert_image_dtype(load(input_filename, channels=input_shape[2]), dtype=tf.float32)

    if preset_name == 'random':
        preset_name = 'random-effect'

    kwargs = presets.preset(preset_name)

    print(kwargs['name'])

    kwargs['time'] = time

    if 'freq' not in kwargs:
        kwargs['freq'] = [3, 3]

    if 'octaves' not in kwargs:
        kwargs['octaves'] = 1

    if 'ridges' not in kwargs:
        kwargs['ridges'] = False

    if no_resize:
        kwargs['shape'] = input_shape

    else:
        kwargs['shape'] = [1024, 1024, input_shape[2]]

        tensor = effects.square_crop_and_resize(tensor, input_shape, kwargs['shape'][0])

    if overrides:
        kwargs.update(json.loads(overrides))

    tensor = effects.post_process(tensor, **kwargs)
    tensor = recipes.post_process(tensor, **kwargs)

    with tf.Session().as_default():
        save(tensor, name)
Exemple #4
0
def main(ctx, width, height, channels, time, clut, seed, overrides, name,
         preset_name):
    presets.bake_presets(seed)

    if preset_name == 'random':
        preset_name = 'random-preset'

    kwargs = presets.preset(preset_name)

    print(kwargs['name'])

    kwargs['shape'] = [height, width, channels]
    kwargs['time'] = time

    if 'freq' not in kwargs:
        kwargs['freq'] = 3

    if 'octaves' not in kwargs:
        kwargs['octaves'] = 1

    if 'ridges' not in kwargs:
        kwargs['ridges'] = False

    if clut:
        kwargs['clut'] = clut
        kwargs['clut_horizontal'] = True

    if overrides:
        kwargs.update(json.loads(overrides))

    # print(json.dumps(kwargs, sort_keys=True, indent=4, default=str))

    tensor = generators.multires(**kwargs)

    tensor = recipes.post_process(tensor, **kwargs)

    with tf.Session().as_default():
        save(tensor, name)
Exemple #5
0
def run_preset(preset_name, shape, filename, tensor=None):
    kwargs = presets.preset(preset_name)

    kwargs['shape'] = shape

    if 'freq' not in kwargs:
        kwargs['freq'] = 3

    if 'octaves' not in kwargs:
        kwargs['octaves'] = 1

    if 'ridges' not in kwargs:
        kwargs['ridges'] = False

    kwargs['post_brightness'] = .125

    if tensor is None:
        tensor = generators.multires(**kwargs)

    tensor = recipes.post_process(tensor, **kwargs)

    with tf.Session().as_default():
        save(tensor, filename)
Exemple #6
0
def render(ctx, glitch, vhs, crt, scan_error, snow, dither, aberration, bloom, name, input_filename):
    tensor = tf.image.convert_image_dtype(load(input_filename), tf.float32)

    freq = [3, 3]

    max_height = 1024
    max_width = 1024

    with tf.Session().as_default():
        height, width, channels = tf.shape(tensor).eval()

        need_resample = False

        if height > max_height:
            need_resample = True
            width = int(width * (max_height / height))
            height = max_height

        if width > max_width:
            need_resample = True
            height = int(height * (max_width / width))
            width = max_width

        shape = [height, width, channels]

        if need_resample:
            tensor = effects.resample(tensor, shape)

        tensor = effects.post_process(tensor, shape=shape, freq=freq, with_bloom=bloom, with_aberration=aberration)

        tensor = recipes.post_process(tensor, shape=shape, freq=freq, with_glitch=glitch, with_vhs=vhs, with_crt=crt,
                                      with_scan_error=scan_error, with_snow=snow, with_dither=dither)

        save(tensor, name)

    print(name)
Exemple #7
0
def main(ctx, freq, width, height, channels, octaves, ridges, post_ridges, sin,
         wavelet, lattice_drift, vortex, warp, warp_octaves, warp_interp,
         warp_freq, reflect, refract, reindex, reverb, reverb_iterations,
         post_reindex, post_reflect, post_refract, clut, clut_horizontal,
         clut_range, ripple, ripple_freq, ripple_kink, worms, worms_density,
         worms_duration, worms_stride, worms_stride_deviation, worms_alpha,
         worms_kink, wormhole, wormhole_kink, wormhole_stride, sobel, outline,
         normals, post_deriv, deriv, deriv_alpha, interp, distrib, corners,
         mask, mask_inverse, posterize, erosion_worms, voronoi, voronoi_func,
         voronoi_nth, voronoi_alpha, voronoi_refract, voronoi_inverse, glitch,
         vhs, crt, scan_error, snow, dither, aberration, light_leak, vignette,
         vignette_brightness, pop, bloom, rgb, hue_range, hue_rotation,
         saturation, saturation_distrib, post_hue_rotation, post_saturation,
         brightness_distrib, input_dir, dla, dla_padding, point_freq,
         point_distrib, point_corners, point_generations, point_drift, shadow,
         density, seed, name, **convolve_kwargs):

    generators.set_seed(seed)

    shape = [height, width, channels]

    tensor = generators.multires(freq=freq,
                                 shape=shape,
                                 octaves=octaves,
                                 ridges=ridges,
                                 post_ridges=post_ridges,
                                 sin=sin,
                                 wavelet=wavelet,
                                 lattice_drift=lattice_drift,
                                 reflect_range=reflect,
                                 refract_range=refract,
                                 reindex_range=reindex,
                                 with_reverb=reverb,
                                 reverb_iterations=reverb_iterations,
                                 post_reindex_range=post_reindex,
                                 post_reflect_range=post_reflect,
                                 post_refract_range=post_refract,
                                 ripple_range=ripple,
                                 ripple_freq=ripple_freq,
                                 ripple_kink=ripple_kink,
                                 clut=clut,
                                 clut_horizontal=clut_horizontal,
                                 clut_range=clut_range,
                                 with_worms=worms,
                                 worms_density=worms_density,
                                 worms_duration=worms_duration,
                                 worms_stride=worms_stride,
                                 worms_stride_deviation=worms_stride_deviation,
                                 worms_alpha=worms_alpha,
                                 worms_kink=worms_kink,
                                 with_wormhole=wormhole,
                                 wormhole_kink=wormhole_kink,
                                 wormhole_stride=wormhole_stride,
                                 with_erosion_worms=erosion_worms,
                                 with_voronoi=voronoi,
                                 voronoi_func=voronoi_func,
                                 voronoi_nth=voronoi_nth,
                                 voronoi_alpha=voronoi_alpha,
                                 voronoi_refract=voronoi_refract,
                                 voronoi_inverse=voronoi_inverse,
                                 with_dla=dla,
                                 dla_padding=dla_padding,
                                 point_freq=point_freq,
                                 point_distrib=point_distrib,
                                 point_corners=point_corners,
                                 point_generations=point_generations,
                                 point_drift=point_drift,
                                 with_outline=outline,
                                 with_sobel=sobel,
                                 with_normal_map=normals,
                                 post_deriv=post_deriv,
                                 deriv=deriv,
                                 deriv_alpha=deriv_alpha,
                                 spline_order=interp,
                                 distrib=distrib,
                                 corners=corners,
                                 mask=mask,
                                 mask_inverse=mask_inverse,
                                 warp_range=warp,
                                 warp_octaves=warp_octaves,
                                 warp_interp=warp_interp,
                                 warp_freq=warp_freq,
                                 posterize_levels=posterize,
                                 vortex_range=vortex,
                                 rgb=rgb,
                                 hue_range=hue_range,
                                 hue_rotation=hue_rotation,
                                 saturation=saturation,
                                 post_hue_rotation=post_hue_rotation,
                                 post_saturation=post_saturation,
                                 brightness_distrib=brightness_distrib,
                                 saturation_distrib=saturation_distrib,
                                 input_dir=input_dir,
                                 with_aberration=aberration,
                                 with_bloom=bloom,
                                 with_pop=pop,
                                 with_light_leak=light_leak,
                                 with_vignette=vignette,
                                 vignette_brightness=vignette_brightness,
                                 with_shadow=shadow,
                                 with_density_map=density,
                                 **convolve_kwargs)

    tensor = recipes.post_process(tensor,
                                  shape=shape,
                                  freq=freq,
                                  with_glitch=glitch,
                                  with_vhs=vhs,
                                  with_crt=crt,
                                  with_scan_error=scan_error,
                                  with_snow=snow,
                                  with_dither=dither)

    with tf.Session().as_default():
        save(tensor, name)

    print(name)