Hi
Im work in pytorch “cycle gan”
My training:
#csv
train_csv_path = ‘fileTrainFinWord.csv’ #TODO 70
val_csv_path = ‘fileVal_fin.csv’ #TODO 20
test_csv_path =‘fileTest_fin.csv’ #TODO 10
train_set = MedicalDataset(train_csv_path)
val_set = MedicalDataset(val_csv_path)
test_set = MedicalDataset(test_csv_path)
train_loader = DataLoader(MedicalDataset(train_csv_path,transform = transform),
batch_size=opt.batch_size,
shuffle=True, num_workers=1)
val_loader = DataLoader(MedicalDataset(val_csv_path,transform = transform ),
batch_size=5,
shuffle=True, num_workers=1)
My class
class MedicalDataset(Dataset):
“”“Low-Dose CT dataset.”“”
def __init__(self,csv_file_path,
root_dir='../input/lowdosect/manifest-1623308542701/LDCT-and-Projection-data/',
transform=None, ):
"""
Args:
root_dir (string): Directory with all the images.
transform (callable, optional): Optional transform to be applied on a sample.
"""
self.root_dir = root_dir
self.img_paths = pd.read_csv(csv_file_path,sep="../input/lowdosect/manifest-1623308542701/metadata.csv",engine='python')
print(self.img_paths)
self.img_paths = self.img_paths.drop(self.img_paths.columns[0], axis=1)
self.len = self.img_paths.shape[0]
self.full =
self.low =
self.fullcache = {}
self.lowcache = {}
if transform:
self.transform = transform
else:
self.transform = transforms.Compose([
transforms.Rescale(255),
transforms.ToTensor()
])
def __len__(self):
return self.len
def __getitem__(self, idx):
if torch.is_tensor(idx):
idx = idx.tolist()
low_dose_path, full_dose_path = self.img_paths.iloc[idx, 0:2]
# till this point we have paths for both low dose and high dose dicom files
# write a function `dicom_to_img` to convert .dicom to image
# and store them in low_dose_img, high_dose_img respectively
low_dose_img, full_dose_img = self.dicom_to_img(low_dose_path, full_dose_path)
if self.transform:
low_dose_img = self.transform(low_dose_img)
full_dose_img = self.transform(full_dose_img)
(low_dose_img, full_dose_img)
return {"A":low_dose_img , "B": full_dose_img}
#return sample
class MedicalDataset(Dataset):
“”“Low-Dose CT dataset.”“”
def __init__(self,csv_file_path,
root_dir='../input/lowdosect/manifest-1623308542701/LDCT-and-Projection-data/',
transform=None, ):
"""
Args:
root_dir (string): Directory with all the images.
transform (callable, optional): Optional transform to be applied on a sample.
"""
self.root_dir = root_dir
self.img_paths = pd.read_csv(csv_file_path,sep="../input/lowdosect/manifest-1623308542701/metadata.csv",engine='python')
print(self.img_paths)
self.img_paths = self.img_paths.drop(self.img_paths.columns[0], axis=1)
self.len = self.img_paths.shape[0]
self.full =
self.low =
self.fullcache = {}
self.lowcache = {}
if transform:
self.transform = transform
else:
self.transform = transforms.Compose([
transforms.Rescale(255),
transforms.ToTensor()
])
def __len__(self):
return self.len
def __getitem__(self, idx):
if torch.is_tensor(idx):
idx = idx.tolist()
low_dose_path, full_dose_path = self.img_paths.iloc[idx, 0:2]
# till this point we have paths for both low dose and high dose dicom files
# write a function `dicom_to_img` to convert .dicom to image
# and store them in low_dose_img, high_dose_img respectively
low_dose_img, full_dose_img = self.dicom_to_img(low_dose_path, full_dose_path)
if self.transform:
low_dose_img = self.transform(low_dose_img)
full_dose_img = self.transform(full_dose_img)
(low_dose_img, full_dose_img)
return {"A":low_dose_img , "B": full_dose_img}
#return sample
i have this Erreur
when i change the Num worker To 0 i have this :
ValueError: not enough values to unpack (expected 2, got 0)
Please help me in figuring out these issues.