INNER CODE UNIT · Python
center_row_rm
Shilin-LU/TF-ICON · scripts/app.py:207
center_row_rm = int(center_row_from_top * target_height)
center_col_rm = int(center_col_from_left * target_width)
step_height2, remainder = divmod(height, 2)
step_height1 = step_height2 + remainder
step_width2, remainder = divmod(width, 2)
step_width1 = step_width2 + remainder
# compositing in pixel space for same-domain composition
save_image[:, :, center_row_rm - step_height1:center_row_rm + step_height2, center_col_rm - step_width1:center_col_rm + step_width2] \
= save_image[:, :, center_row_rm - step_height1:center_row_rm + step_height2, center_col_rm - step_width1:center_col_rm + step_width2].clone() \
* (1 - segmentation_map_save[:, :, top_rr:bottom_rr, left_rr:right_rr]) \
+ ref_image[:, :, top_rr:bottom_rr, left_rr:right_rr].clone() \
* segmentation_map_save[:, :, top_rr:bottom_rr, left_rr:right_rr]
# save the mask and the pixel space composited image
save_mask = torch.zeros_like(init_image)
save_mask[:, :, center_row_rm - step_height1:center_row_rm + step_height2, center_col_rm - step_width1:center_col_rm + step_width2] = 1