INNER CODE UNIT · Python

data

Shilin-LU/TF-ICON · scripts/app.py:188

    data = [batch_size * [prompt]]
    # read background image              
    init_image, target_width, target_height = load_img(init_img, mask_scale)
    init_image = repeat(init_image.to(device), '1 ... -> b ...', b=batch_size)
    save_image = init_image.clone()

    # read foreground image and its segmentation map
    ref_image, width, height, segmentation_map  = load_img(ref_img, mask_scale, seg_map=seg, target_size=(target_width, target_height))
    ref_image = repeat(ref_image.to(device), '1 ... -> b ...', b=batch_size)

    segmentation_map_orig = repeat(torch.tensor(segmentation_map)[None, None, ...].to(device), '1 1 ... -> b 4 ...', b=batch_size)
    segmentation_map_save = repeat(torch.tensor(segmentation_map)[None, None, ...].to(device), '1 1 ... -> b 3 ...', b=batch_size)
    segmentation_map = segmentation_map_orig[:, :, ::8, ::8].to(device)

    top_rr = int((0.5*(target_height - height))/target_height * init_image.shape[2])  # xx% from the top
    bottom_rr = int((0.5*(target_height + height))/target_height * init_image.shape[2])  
    left_rr = int((0.5*(target_width - width))/target_width * init_image.shape[3])  # xx% from the left
    right_rr = int((0.5*(target_width + width))/target_width * init_image.shape[3]) 

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…