Update dataset/datasets.py
Browse files- dataset/datasets.py +5 -2
dataset/datasets.py
CHANGED
|
@@ -21,8 +21,11 @@ class TrainDataset(torch.utils.data.Dataset):
|
|
| 21 |
def __getitem__(self, idx):
|
| 22 |
image_name = self.data[idx]
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
if self.mults_amount > 1:
|
| 28 |
mult_number = np.random.choice(range(self.mults_amount))
|
|
|
|
| 21 |
def __getitem__(self, idx):
|
| 22 |
image_name = self.data[idx]
|
| 23 |
|
| 24 |
+
try:
|
| 25 |
+
color_img = plt.imread(os.path.join(self.data_path, 'color', image_name))
|
| 26 |
+
except SyntaxError:
|
| 27 |
+
print(f"Archivo {image_name} no es un PNG válido. Saltando...")
|
| 28 |
+
return None # O alguna otra acción que prefieras
|
| 29 |
|
| 30 |
if self.mults_amount > 1:
|
| 31 |
mult_number = np.random.choice(range(self.mults_amount))
|