INNER CODE UNIT · Python
mask_scale
Shilin-LU/TF-ICON · scripts/app.py:182
mask_scale = new_h / (aspect_ratio * 256)
# mask_scale = round(mask_scale, 2)
# =============================================================================================
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)