One-Shot-Face-Swapping-on-Megapixels
One-Shot-Face-Swapping-on-Megapixels copied to clipboard
inference dataset path
I have downloaded CelebAMask-HQ and CelebA-HQ Their directory structure is as follows:
CelebAMask-HQ:

def read_pair(self, src_idx, tgt_idx):
src_face = cv2.imread(os.path.join(self.img_root, "{}.jpg".format(src_idx)))
tgt_face = cv2.imread(os.path.join(self.img_root, "{}.jpg".format(tgt_idx)))
tgt_mask = cv2.imread(os.path.join(self.mask_root, "{}.png".format(tgt_idx)))
src_face_rgb = src_face[:, :, ::-1]
tgt_face_rgb = tgt_face[:, :, ::-1]
tgt_mask = encode_segmentation_rgb(tgt_mask)
return src_face_rgb, tgt_face_rgb, tgt_mask
It looks like this code does not match this directory structure Am I missing something? How can I set the image path during inference
Well, as you can see the src_face, tgt_face and tgt_mask are images read by cv2, you don't need to take care of the directory structure. Just give the correct paths of src_face, tgt_face and tgt_mask to cv2.imread(PATH) should work well.
And the indexes of target image and mask should be same.
mask images can't read in this path
It seems mask image name not match the code tgt_mask = cv2.imread(os.path.join(self.mask_root, "{}.png".format(tgt_idx)))
shuoud I make mask image by myself
Yes. In your case, you need to merge multiple images into a single one, valued by semantic index. You may refer to this link for more details on how to merge annotations.