zyainfal / One-Shot-Face-Swapping-on-Megapixels

One Shot Face Swapping on Megapixels.
Other
314 stars 40 forks source link

inference dataset path #20

Open RRdmlearning opened 2 years ago

RRdmlearning commented 2 years ago

I have downloaded CelebAMask-HQ and CelebA-HQ Their directory structure is as follows:

CelebAMask-HQ:

363J0RHY2E5C5A@PW63TW~H

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

zyainfal commented 2 years ago

Well, as you can see the src_face, tgt_face and tgt_maskare 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.

I8Robot commented 2 years ago

mask images can't read in this path

I8Robot commented 2 years ago

image 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

zyainfal commented 2 years ago

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.