Update soybean_dataset.py
Browse files- soybean_dataset.py +3 -3
soybean_dataset.py
CHANGED
@@ -121,21 +121,21 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
121 |
datasets.SplitGenerator(
|
122 |
name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["valid"]}),
|
123 |
]
|
124 |
-
def background(f):
|
125 |
def wrapped(*args, **kwargs):
|
126 |
return asyncio.get_event_loop().run_in_executor(None, f, *args, **kwargs)
|
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(self, image_url):
|
138 |
-
response = download(image_url)
|
139 |
img = Image.open(BytesIO(response.content))
|
140 |
return img
|
141 |
|
|
|
121 |
datasets.SplitGenerator(
|
122 |
name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["valid"]}),
|
123 |
]
|
124 |
+
def background(self,f):
|
125 |
def wrapped(*args, **kwargs):
|
126 |
return asyncio.get_event_loop().run_in_executor(None, f, *args, **kwargs)
|
127 |
return wrapped
|
128 |
|
129 |
@background
|
130 |
# Define the download function that returns the response object
|
131 |
+
def download(self,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(self, image_url):
|
138 |
+
response = self.download(image_url)
|
139 |
img = Image.open(BytesIO(response.content))
|
140 |
return img
|
141 |
|