FastAi version: 2.7.11
# Download 1 sample good car for prediction after training the model
urls = search_images('2000 to 2023 cars exterior photos', max_images=1)
dest_filename = "good-car.jpg"
download_url(urls[0], dest_filename, show_progress=False)
Image.open(dest_filename).to_thumb(256,256)
Canceled run as it was taking long
Stack Trace
--------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
/tmp/ipykernel_17/3544359861.py in <module>
1 # Download 1 sample good car for prediction after training the model
2 dest_filename = "good-car.jpg"
----> 3 download_url(urls[0], dest_filename, show_progress=False)
4 Image.open(dest_filename).to_thumb(256,256)
/opt/conda/lib/python3.7/site-packages/fastdownload/core.py in download_url(url, dest, timeout, show_progress)
21 pbar.total = tsize
22 pbar.update(count*bsize)
---> 23 return urlsave(url, dest, reporthook=progress if show_progress else None, timeout=timeout)
24
25 # Cell
/opt/conda/lib/python3.7/site-packages/fastcore/net.py in urlsave(url, dest, reporthook, headers, timeout)
182 dest = urldest(url, dest)
183 dest.parent.mkdir(parents=True, exist_ok=True)
--> 184 nm,msg = urlretrieve(url, dest, reporthook, headers=headers, timeout=timeout)
185 return nm
186
/opt/conda/lib/python3.7/site-packages/fastcore/net.py in urlretrieve(url, filename, reporthook, data, headers, timeout)
147 def urlretrieve(url, filename=None, reporthook=None, data=None, headers=None, timeout=None):
148 "Same as `urllib.request.urlretrieve` but also works with `Request` objects"
--> 149 with contextlib.closing(urlopen(url, data, headers=headers, timeout=timeout)) as fp:
150 headers = fp.info()
151 if filename: tfp = open(filename, 'wb')
/opt/conda/lib/python3.7/site-packages/fastcore/net.py in urlopen(url, data, headers, timeout, **kwargs)
106 if not isinstance(data, (str,bytes)): data = urlencode(data)
107 if not isinstance(data, bytes): data = data.encode('ascii')
--> 108 try: return urlopener().open(urlwrap(url, data=data, headers=headers), timeout=timeout)
109 except HTTPError as e:
110 e.msg += f"\n====Error Body====\n{e.read().decode(errors='ignore')}"
/opt/conda/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
523 req = meth(req)
524
--> 525 response = self._open(req, data)
526
527 # post-process response
/opt/conda/lib/python3.7/urllib/request.py in _open(self, req, data)
541 protocol = req.type
542 result = self._call_chain(self.handle_open, protocol, protocol +
--> 543 '_open', req)
544 if result:
545 return result
/opt/conda/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
501 for handler in handlers:
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
505 return result
/opt/conda/lib/python3.7/urllib/request.py in https_open(self, req)
1391 def https_open(self, req):
1392 return self.do_open(http.client.HTTPSConnection, req,
-> 1393 context=self._context, check_hostname=self._check_hostname)
1394
1395 https_request = AbstractHTTPHandler.do_request_
/opt/conda/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)
1351 except OSError as err: # timeout error
1352 raise URLError(err)
-> 1353 r = h.getresponse()
1354 except:
1355 h.close()
/opt/conda/lib/python3.7/http/client.py in getresponse(self)
1371 try:
1372 try:
-> 1373 response.begin()
1374 except ConnectionError:
1375 self.close()
/opt/conda/lib/python3.7/http/client.py in begin(self)
317 # read until we get a non-100 response
318 while True:
--> 319 version, status, reason = self._read_status()
320 if status != CONTINUE:
321 break
/opt/conda/lib/python3.7/http/client.py in _read_status(self)
278
279 def _read_status(self):
--> 280 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
281 if len(line) > _MAXLINE:
282 raise LineTooLong("status line")
/opt/conda/lib/python3.7/socket.py in readinto(self, b)
587 while True:
588 try:
--> 589 return self._sock.recv_into(b)
590 except timeout:
591 self._timeout_occurred = True
/opt/conda/lib/python3.7/ssl.py in recv_into(self, buffer, nbytes, flags)
1069 "non-zero flags not allowed in calls to recv_into() on %s" %
1070 self.__class__)
-> 1071 return self.read(nbytes, buffer)
1072 else:
1073 return super().recv_into(buffer, nbytes, flags)
/opt/conda/lib/python3.7/ssl.py in read(self, len, buffer)
927 try:
928 if buffer is not None:
--> 929 return self._sslobj.read(len, buffer)
930 else:
931 return self._sslobj.read(len)
KeyboardInterrupt: