Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -86,7 +86,6 @@ class Pix2PixDataset(torch.utils.data.Dataset):
|
|
86 |
return len(self.originals)
|
87 |
|
88 |
def __getitem__(self, idx):
|
89 |
-
# Get original and target images
|
90 |
original_img = self.originals[idx]['image']
|
91 |
target_img = self.targets[idx]['image']
|
92 |
|
@@ -94,12 +93,12 @@ class Pix2PixDataset(torch.utils.data.Dataset):
|
|
94 |
original = original_img.convert('RGB')
|
95 |
target = target_img.convert('RGB')
|
96 |
|
97 |
-
# Extract the filename from the
|
98 |
-
original_img_path =
|
99 |
original_img_filename = os.path.basename(original_img_path)
|
100 |
-
|
101 |
# Match the image filename with the `image_path` column in the CSV
|
102 |
-
matched_row = self.data[self.data['image_path'].str.
|
103 |
|
104 |
if matched_row.empty:
|
105 |
raise ValueError(f"No matching entry found in the CSV for image {original_img_filename}")
|
|
|
86 |
return len(self.originals)
|
87 |
|
88 |
def __getitem__(self, idx):
|
|
|
89 |
original_img = self.originals[idx]['image']
|
90 |
target_img = self.targets[idx]['image']
|
91 |
|
|
|
93 |
original = original_img.convert('RGB')
|
94 |
target = target_img.convert('RGB')
|
95 |
|
96 |
+
# Extract the filename from the image_path in the CSV
|
97 |
+
original_img_path = self.data.iloc[idx]['image_path']
|
98 |
original_img_filename = os.path.basename(original_img_path)
|
99 |
+
|
100 |
# Match the image filename with the `image_path` column in the CSV
|
101 |
+
matched_row = self.data[self.data['image_path'].str.endswith(original_img_filename)]
|
102 |
|
103 |
if matched_row.empty:
|
104 |
raise ValueError(f"No matching entry found in the CSV for image {original_img_filename}")
|