back to original
Browse files- soybean_dataset.py +6 -14
soybean_dataset.py
CHANGED
@@ -130,25 +130,15 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
130 |
img = Image.open(BytesIO(response.content))
|
131 |
return img
|
132 |
|
|
|
|
|
133 |
def _generate_examples(self, filepath):
|
134 |
#"""Yields examples as (key, example) tuples."""
|
135 |
logging.info("generating examples from = %s", filepath)
|
136 |
-
|
137 |
-
# Create a future to image mapping
|
138 |
-
future_to_image = {executor.submit(self.process_image, row['original_image']): row for row in data}
|
139 |
-
|
140 |
-
for future in as_completed(future_to_image):
|
141 |
-
row = future_to_image[future]
|
142 |
-
try:
|
143 |
-
original_image = future.result() # This will block until the image is ready
|
144 |
-
# ... do something with the original_image ...
|
145 |
-
except Exception as e:
|
146 |
-
logging.error(f"Error processing image: {e}")
|
147 |
-
continue
|
148 |
-
|
149 |
with open(filepath, encoding="utf-8") as f:
|
150 |
data = csv.DictReader(f)
|
151 |
-
|
152 |
|
153 |
for row in data:
|
154 |
# Assuming the 'original_image' column has the full path to the image file
|
@@ -171,6 +161,8 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
171 |
# ... add other features if necessary
|
172 |
}
|
173 |
|
|
|
|
|
174 |
|
175 |
|
176 |
|
|
|
130 |
img = Image.open(BytesIO(response.content))
|
131 |
return img
|
132 |
|
133 |
+
|
134 |
+
|
135 |
def _generate_examples(self, filepath):
|
136 |
#"""Yields examples as (key, example) tuples."""
|
137 |
logging.info("generating examples from = %s", filepath)
|
138 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
with open(filepath, encoding="utf-8") as f:
|
140 |
data = csv.DictReader(f)
|
141 |
+
|
142 |
|
143 |
for row in data:
|
144 |
# Assuming the 'original_image' column has the full path to the image file
|
|
|
161 |
# ... add other features if necessary
|
162 |
}
|
163 |
|
164 |
+
|
165 |
+
|
166 |
|
167 |
|
168 |
|