Update soybean_dataset.py
Browse files- soybean_dataset.py +11 -10
soybean_dataset.py
CHANGED
@@ -127,17 +127,18 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
127 |
return wrapped
|
128 |
|
129 |
@background
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
|
143 |
|
|
|
127 |
return wrapped
|
128 |
|
129 |
@background
|
130 |
+
# Define the download function that returns the response object
|
131 |
+
def download(url):
|
132 |
+
r = requests.get(url)
|
133 |
+
r.raise_for_status() # This will raise an exception if there is a download error
|
134 |
+
return r
|
135 |
|
136 |
+
# Define the process_image function that uses the response from download
|
137 |
+
def process_image(image_url):
|
138 |
+
response = download(image_url)
|
139 |
+
img = Image.open(BytesIO(response.content))
|
140 |
+
return img
|
141 |
+
|
142 |
|
143 |
|
144 |
|