Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AFHQ Dataset #16

Open
omar-abdelgawad opened this issue Dec 21, 2023 · 0 comments
Open

Fix AFHQ Dataset #16

omar-abdelgawad opened this issue Dec 21, 2023 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@omar-abdelgawad
Copy link
Owner

Describe the bug
The current AFHQ dataset implementation that has been merged needs correction as the code inside is for colorizatoin datasets and doesn't work with the afhq dataset format.

Expected behavior

Screenshots
Just for reference the following code in src/tunit/dataset.py is the code to be changed. Please note that the method to fully change is the getitem only.

class AFHQCatDataset(Dataset):
    """Dataset class for AFHQ Cat Colorization dataset.

    Args:
        root_dir (root_dir): Path for dataset dir.
    """

    def __init__(self, root_dir: Path | str) -> None:
        self.root_dir = root_dir
        self.list_files = os.listdir(self.root_dir)[: cfg.NUM_IMAGES_DATASET]
        print(f"The length of the dataset is: {len(self.list_files)}")

    def __len__(self):
        return len(self.list_files)

    def __getitem__(self, index):
        img_file_name = self.list_files[index]
        img_path = os.path.join(self.root_dir, img_file_name)
        image = np.array(Image.open(img_path))
        target_image = image[:, : image.shape[1] // 2, :]
        input_image = image[:, image.shape[1] // 2 :, :]

        augmentations = cfg.both_transform(image=input_image, image0=target_image)
        input_image, target_image = augmentations["image"], augmentations["image0"]

        input_image = cfg.transform_only_input(image=input_image)["image"]
        target_image = cfg.transform_only_mask(image=target_image)["image"]

        return input_image, target_image

Additional context
For additional information please ask or contact me directly whichever is easier for you.

@omar-abdelgawad omar-abdelgawad added bug Something isn't working good first issue Good for newcomers labels Dec 21, 2023
@khaled-gad khaled-gad self-assigned this Dec 22, 2023
@omar-abdelgawad omar-abdelgawad removed this from the TUNIT Implementation milestone Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants