lisawen commited on
Commit
7ef84f6
1 Parent(s): 6f462b4

Update soybean_dataset.py

Browse files
Files changed (1) hide show
  1. soybean_dataset.py +11 -10
soybean_dataset.py CHANGED
@@ -127,17 +127,18 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
127
  return wrapped
128
 
129
  @background
130
- def download(url, fn):
131
- r = requests.get(url)
132
-
133
-
 
134
 
135
- def process_image(self,image_url):
136
- response = download(image_url)
137
-
138
- # Open the image from the downloaded bytes and return the PIL Image
139
- img = Image.open(BytesIO(response.content))
140
- return img
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