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

huangapple go评论52阅读模式
英文:

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

问题

当我尝试从tensorflow hub加载模型时

```python
输入形状 = [无IMG_SIZEIMG_SIZE3]

输出形状 = len(unique_labels)

模型网址 = "https://tfhub.dev/google/imagenet/mobilenet_v2_130_224/classification/5"

def create_model(input_shape, output_shape, model_url):
  print("使用以下构建模型", model_url)
  model = tf.keras.Sequential([
      hub.KerasLayer(model_url), # 第1层,输入层
      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)

我收到以下错误信息:“SSLCertVerificationError ...”,最后显示:“URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>”。

我知道这里曾经有过类似的问题,但我没有安装Certificate.command脚本(可能是因为我在Windows上),而且我已经安装了certifi。

我刚刚下载了64位的miniconda3 for windows,并按照Microsoft的教程安装了tensorflow-directml-plugin。

之后我执行了:pip install jupyter pandas numpy scikit-learn tensorflow-hub matplotlib

在启动jupyter notebook并尝试运行我的代码后,出现了这个错误。

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

我不知道如何解决这个问题。


<details>
<summary>英文:</summary>

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

```python
INPUT_SHAPE = [None, IMG_SIZE, IMG_SIZE, 3]

OUTPUT_SHAPE = len(unique_labels)

MODEL_URL = &quot;https://tfhub.dev/google/imagenet/mobilenet_v2_130_224/classification/5&quot;

def create_model(input_shape, output_shape, model_url):
  print(&quot;Building model with:&quot;, model_url)
  model = tf.keras.Sequential([
      hub.KerasLayer(model_url), # Layer 1, the input layer
      tf.keras.layers.Dense(units=output_shape,
                     activation=&quot;softmax&quot;) 
  ])
  model.compile(
      loss = tf.keras.losses.CategoricalCrossentropy(),
      optimizer = tf.keras.optimizers.Adam(),
      metrics=[&quot;accuracy&quot;]
  )
  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.

答案1

得分: 0

我简单地通过删除python、miniconda3和所有缓存来解决了这个问题。重新安装后,一切都正常工作。

英文:

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

huangapple
  • 本文由 发表于 2023年5月18日 06:01:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76276468.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定