jupyter-notebookminicondatensorflow-hub

miniconda3 -> Jupyter -> tensorflow-hub -> [SSL: CERTIFICATE_VERIFY_FAILED]


When I try to load a model from tensorflow hub like:

INPUT_SHAPE = [None, IMG_SIZE, IMG_SIZE, 3]

OUTPUT_SHAPE = len(unique_labels)

MODEL_URL = "https://tfhub.dev/google/imagenet/mobilenet_v2_130_224/classification/5"

def create_model(input_shape, output_shape, model_url):
  print("Building model with:", model_url)
  model = tf.keras.Sequential([
      hub.KerasLayer(model_url), # Layer 1, the input layer
      tf.keras.layers.Dense(units=output_shape,
                     activation="softmax") 
  ])
  model.compile(
      loss = tf.keras.losses.CategoricalCrossentropy(),
      optimizer = tf.keras.optimizers.Adam(),
      metrics=["accuracy"]
  )
  model.build(input_shape)
  return model

model = create_model(INPUT_SHAPE, OUTPUT_SHAPE, MODEL_URL)

I get the following error: "SSLCertVerificationError ..." and at the end of it: "URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>" .

I know there have been similar problems posted here, but i dont have the install Certificate.command script(meybe because I'm on windows), and I have installed certifi.

I just downloaded 64 bit miniconda3 for windows, and I followed Microsoft tutorial for tensorflow-directml-plugin.

After that I did: pip install jupyter pandas numpy scikit-learn tensorflow-hub matplotlib

And after launching jupyter notebook and trying to run my code this error popped up.

certifi.where() returns: 'C:\Users\djord\miniconda3\envs\tfdml_plugin\lib\site-packages\certifi\cacert.pem'

I have no idea how to fix this.


Solution

  • For anyone seeing this, I simply solved the issue by deleting python, miniconda3 and all caches. After installing it all back, it just worked.