Ejemplo n.º 1
0
def preprocess_image(x, img_width, img_height):
    img = imresize(x, (img_height, img_width),
                   interp='bicubic').astype('float64')
    img = vgg16.img_to_vgg(img)
    img = np.expand_dims(img, axis=0)
    return img
Ejemplo n.º 2
0
            full_img_width = int(round(args.out_height / float(full_img_height) * full_img_width))
            full_img_height = args.out_height

b_scale_ratio_width = float(full_b_image.shape[1]) / full_img_width
b_scale_ratio_height = float(full_b_image.shape[0]) / full_img_height

x = None
for scale_i in range(num_scales):
    scale_factor = (scale_i * step_scale_factor) + min_scale_factor
    # scale our inputs
    img_width = int(round(full_img_width * scale_factor))
    img_height = int(round(full_img_height * scale_factor))
    img_width, img_height = img_width, img_height
    if x is None:
        x = np.random.uniform(0, 255, (img_height, img_width, 3))
        x = vgg16.img_to_vgg(x)
    else:  # resize the last state
        zoom_ratio = img_width / float(x.shape[-1])
        x = scipy.ndimage.zoom(x, (1, zoom_ratio, zoom_ratio), order=1)
        img_height, img_width = x.shape[-2:]

    if a_scale_mode == 'match':
        a_img_width = img_width
        a_img_height = img_height
    elif a_scale_mode == 'none':
        a_img_width = full_a_image.shape[1] * scale_factor
        a_img_height = full_a_image.shape[0] * scale_factor
    else:  # should just be 'ratio'
        a_img_width = full_a_image.shape[1] * scale_factor * b_scale_ratio_width
        a_img_height = full_a_image.shape[0] * scale_factor * b_scale_ratio_height
    a_img_width = int(round(args.a_scale * a_img_width))
Ejemplo n.º 3
0
                      full_img_width))
            full_img_height = args.out_height

b_scale_ratio_width = float(full_b_image.shape[1]) / full_img_width
b_scale_ratio_height = float(full_b_image.shape[0]) / full_img_height

x = None
for scale_i in range(num_scales):
    scale_factor = (scale_i * step_scale_factor) + min_scale_factor
    # scale our inputs
    img_width = int(round(full_img_width * scale_factor))
    img_height = int(round(full_img_height * scale_factor))
    img_width, img_height = img_width, img_height
    if x is None:
        x = np.random.uniform(0, 255, (img_height, img_width, 3))
        x = vgg16.img_to_vgg(x)
    else:  # resize the last state
        zoom_ratio = img_width / float(x.shape[-1])
        x = scipy.ndimage.zoom(x, (1, zoom_ratio, zoom_ratio), order=1)
        img_height, img_width = x.shape[-2:]

    if a_scale_mode == 'match':
        a_img_width = img_width
        a_img_height = img_height
    elif a_scale_mode == 'none':
        a_img_width = full_a_image.shape[1] * scale_factor
        a_img_height = full_a_image.shape[0] * scale_factor
    else:  # should just be 'ratio'
        a_img_width = full_a_image.shape[1] * scale_factor * b_scale_ratio_width
        a_img_height = full_a_image.shape[
            0] * scale_factor * b_scale_ratio_height
Ejemplo n.º 4
0
def preprocess_image(x, img_width, img_height):
    img = imresize(x, (img_height, img_width), interp='bicubic').astype('float64')
    img = vgg16.img_to_vgg(img)
    img = np.expand_dims(img, axis=0)
    return img