YU1ut / MixMatch-pytorch

Code for "MixMatch - A Holistic Approach to Semi-Supervised Learning"
MIT License
633 stars 129 forks source link

How to apply it to my own dataset? #34

Open ghost opened 3 years ago

ghost commented 3 years ago

I tried to apply it to my own dataset, but it didn't work because unmarked data had to be enhanced twice. Thank you very much for who can help me

sakumashirayuki commented 3 years ago

what is your problem? I suggest write your own dataset class to read your images. Here is the dataset class read images from a path

class YourDatasetName(Dataset):
    def __init__(self, root_dir, transform=None):
        self.root_dir = root_dir
        self.transform = transform
        self.image_lists = os.listdir(root_dir)

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

    def __getitem__(self, item):
        image_path = os.path.join(self.root_dir, self.image_lists[item])
        image = Image.open(image_path)
        image = image.convert('RGB')
        if self.transform:
            img_tensor_1 = self.transform(image)
            img_tensor_2 = self.transform(image)
        return img_tensor_1, img_tensor_2
ghost commented 3 years ago

Thank you for your help. Under your inspiration, I solved this problem. Thank you very much

thiyagu145 commented 3 years ago

@sakumashirayuki Have you tried training in a multi gpu setting with DP/DDP?