helloall this is my first post.
I am currently halfway through a Udemy course titled "Build and train a data model to recognize objects in images!" (https://www.udemy.com/course/pythondatascience/) and am having difficulty with one of the tasks (running on a 2019 MacBook Pro with 10.15.6, using PyCharm IDE).
The task requires to run the code below to open/render an image from the CiFAR10 dataset:
from PIL import Image
labels = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
from keras.datasets import cifar10
# X_train = images, y_train = labels
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
index = 5
display_image = X_train[index]
display_label = y_train[index][0]
from matplotlib import pyplot as plt
final_image = plt.imshow(display_image)
final_image.show()
However I get the following errors and do not know what to do. I have posted on the course but being 3 years old, I don’t think anyone is keeping up to date with it and am not getting and responses.
/Users/muratuckan/PycharmProjects/TensorFlow/venv/bin/python /Users/muratuckan/PycharmProjects/TensorFlow/ImageRecognitionTrainer.py
Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1350, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1010, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 950, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1424, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/muratuckan/PycharmProjects/TensorFlow/venv/lib/python3.8/site-packages/tensorflow/python/keras/utils/data_utils.py", line 278, in get_file
urlretrieve(origin, fpath, dl_progress)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1393, in https_open
return self.do_open(http.client.HTTPSConnection, req,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1353, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/muratuckan/PycharmProjects/TensorFlow/ImageRecognitionTrainer.py", line 19, in <module>
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
File "/Users/muratuckan/PycharmProjects/TensorFlow/venv/lib/python3.8/site-packages/tensorflow/python/keras/datasets/cifar10.py", line 52, in load_data
path = get_file( dirname, origin=origin, untar=True)
File "/Users/muratuckan/PycharmProjects/TensorFlow/venv/lib/python3.8/site-packages/tensorflow/python/keras/utils/data_utils.py", line 282, in get_file
raise Exception(error_msg.format(origin, e.errno, e.reason))
Exception: URL fetch failure on https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
Process finished with exit code 1
The only information I have found mentions that I might have an unstable internet connection, but that is not the case.
With some of the posts I notice that their run terminal says "Using TensorFlow backend" however mine does not say this, it only says "Downloading data from https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz"
Please help. Thank you