I m having an error while trying to fetch VGG16 using visual studio code. The code is as shown
import tensorflow as tf
import glob
import os
import pandas as pd
import shutil
path = 'c:/Users/Eric koh/Desktop/Jupyter/ML Project/train/*.jpg'
train_path = 'c:/Users/Eric koh/Desktop/Jupyter/ML Project/train/'
df = pd.read_csv('c:/Users/Eric koh/Desktop/Jupyter/ML Project/labels.csv')
for file in glob.glob(path):
id = (file.split("\\")[1]).split(".")[0]
breed = df.loc[df.id == id]['breed'].values[0]
if os.path.isdir(train_path + breed) is False:
os.makedirs(train_path + breed)
shutil.move(file, train_path +breed)
# Importing data
ds_train = tf.keras.preprocessing.image_dataset_from_directory(
train_path,
labels = 'inferred',
label_mode = 'int',
color_mode = 'rgb',
batch_size = 32,
image_size = (180, 180),
shuffle = True,
seed = 111,
validation_split = 0.2,
subset = 'training'
)
ds_validation = tf.keras.preprocessing.image_dataset_from_directory(
train_path,
labels = 'inferred',
label_mode = 'int',
color_mode = 'rgb',
batch_size = 32,
image_size = (180, 180),
shuffle = True,
seed = 111,
validation_split = 0.2,
subset = 'validation'
)
model = tf.keras.applications.VGG16(
include_top=False,
weights='imagenet',
input_shape=(180,180,3),
classes=120,
classifier_activation='softmax'
)
The error happens when it tries to run tf.keras.applications.VGG16()
The error log is as shown
Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/vgg16/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5
Traceback (most recent call last):
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\site-packages\tensorflow\python\keras\utils\data_utils.py", line 275, in get_file
urlretrieve(origin, fpath, dl_progress)
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\urllib\request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\urllib\request.py", line 548, in _open
'unknown_open', req)
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\urllib\request.py", line 1420, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib.error.URLError: <urlopen error unknown url type: https>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/Users/Eric koh/Desktop/Jupyter/ML Project/ML_on_dog_breed.py", line 111, in <module>
model = model.VGG16.build(width, height)
File "c:\Users\Eric koh\Desktop\Jupyter\ML Project\model.py", line 193, in build
classifier_activation='softmax',
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\site-packages\tensorflow\python\keras\applications\vgg16.py", line 221, in VGG16
file_hash='6d6bbae143d832006294945121d1f1fc')
File "D:\Program File (x86)\anaconda3\envs\tensor\lib\site-packages\tensorflow\python\keras\utils\data_utils.py", line 279, in get_file
raise Exception(error_msg.format(origin, e.errno, e.reason))
Exception: URL fetch failure on https://storage.googleapis.com/tensorflow/keras-applications/vgg16/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5: None -- unknown url type: https
I suspect it might be a connection error from VS code therefore unable to download it, however, I can't seem to get it to download VGG16. Is this a configuration error of sort?