Пример #1
0
def add_clearing_circle(current_img, pattern_step, offset, size, weight=0.25):
    if pattern_step >= offset and pattern_step < offset + size:
        ring_id = pattern_step - offset
        circle_img = circle_masks[ring_id]
        return tfi.masked_mix(current_img, ref_img, circle_img, weight)
    elif pattern_step >= offset + size and pattern_step < offset + size + 4:
        return tfi.mix_images(current_img, ref_img, 1.0 - weight)
    else:
        return current_img
Пример #2
0
def process_image_step(current_img, zoom, rot, mix_ratio, mix_img, target):
    current_img = tfi.affine_zoom(current_img, zoom, rot)
    current_img = tfi.mix_images(current_img, mix_img, mix_ratio)
    return tfi.render_deepdream(target,
                                current_img,
                                iter_n=2,
                                step=1.5,
                                octave_n=4,
                                octave_scale=1.5,
                                direct_objective=True)
    # This should line up with 960 being reverse of same thing in stage_01, which we want!
    if (fno % 480) < 240:
        rot = -rot

    if (fno > 970):
        if (fno % 240) < 10:
            rot *= (fno % 240) / 10.0

        if (fno % 240) > 230:
            rot *= (240 - (fno % 240)) / 10.0

    step_val = 1.25
    if (fno > 4600):
        step_val = 0.5 + 0.75 * (4800 - fno) / 200.0

    current_img = tfi.mix_images(current_img, colour_guides[section_id % 4],
                                 0.997)
    current_img = tfi.affine_zoom(current_img, zoom, rot)
    current_img = tfi.render_deepdream(target,
                                       current_img,
                                       iter_n=1,
                                       step=step_val,
                                       octave_n=4,
                                       octave_scale=1.5,
                                       direct_objective=True)
    cropped_img = current_img[margin:-margin, margin:-margin, :]
    tfi.savejpeg(cropped_img,
                 ('{}/frame_{}.jpeg'.format(directory, '%04d' % fno)))

    if (fno < 1201):
        tfi.savejpeg(
            current_img,
Пример #4
0
    layer_1 = targets[section_id * 2]
    channel_1 = targets[section_id * 2 + 1]

    target = tf.reduce_mean(tfi.T(layer_1)[:, :, :, channel_1])

    delta_rot = 0.1
    delta_zoom = 1.05

    total_rot += delta_rot
    total_zoom *= delta_zoom

    current_img = tfi.affine_zoom(current_img, delta_zoom, delta_rot)

    r = (fno - start_frame) / (end_frame - start_frame)
    mix_amount = 0.99 * (1 - r) + 0.96 * r
    current_img = tfi.mix_images(current_img, end_colours, mix_amount)
    current_img = tfi.render_deepdream(target,
                                       current_img,
                                       iter_n=2,
                                       step=1.5,
                                       octave_n=4,
                                       octave_scale=1.5,
                                       direct_objective=True)

    display_img = current_img
    # Fade to black
    if (fno > 5400):
        fade_r = 1.0 - (fno - 5400) / 45.0
        display_img = tfi.mix_images(display_img, complete_fade_img, fade_r)

    # Fade in credits
Пример #5
0
            target = ri *  tf.reduce_mean( tfi.T(layer_1)[:,:,:,channel_1] ) + r * tf.reduce_mean( tfi.T(layer_2)[:,:,:,channel_2] )
    else:
        target = tf.reduce_mean( tfi.T(layer_2)[:,:,:,channel_2] )

    delta_rot = transition_rot
    delta_zoom = transition_zoom

    if ( fno % 240 ) > 230:
        delta_rot *= ( 240 - ( fno % 240 ) ) / 10.0

    if fno > 980 and ( fno % 240 ) < 10:
        delta_rot *= ( fno % 240 ) / 10.0

    total_rot += delta_rot
    total_zoom *= delta_zoom

    current_img = tfi.affine_zoom( current_img, delta_zoom, delta_rot )
    ref_img = tfi.affine_zoom( img0, total_zoom, total_rot )
    current_img = tfi.mix_images( current_img, ref_img, 0.998 )
    current_img = tfi.mix_images( current_img, end_colours, 0.99 )
    current_img = tfi.render_deepdream( target, current_img, iter_n=1, step=1.5, octave_n=4, octave_scale=1.5, direct_objective = True )

    tfi.savejpeg( current_img, ('{}/overlap_frame_{}.jpeg'.format( directory, '%04d' % fno ) ) )

    cropped_img = current_img[margin:-margin, margin:-margin, :]
    tfi.savejpeg( cropped_img, ('{}/frame_{}.jpeg'.format( directory, '%04d' % fno ) ) )

    if (frame % 5 == 0):
        tfi.reset_graph_and_session()

tfi.close_session()