当前位置: 代码迷 >> 综合 >> tensorflow keras模型Exception: URL fetch failure on https://storage.googleapis.com/keras-applications
  详细解决方案

tensorflow keras模型Exception: URL fetch failure on https://storage.googleapis.com/keras-applications

热度:9   发布时间:2023-12-15 16:30:12.0

linux ubuntu tensorflow.keras加载模型报错(代码自动下载模型):
代码:

from omegaconf import OmegaConf
cfg = OmegaConf.from_dotlist([f"model.model_name={model_name}", f"model.img_size={img_size}"])
from tensorflow.keras import applications
base_model = getattr(applications, cfg.model.model_name)(include_top=False,input_shape=(cfg.model.img_size, cfg.model.img_size, 3),pooling="avg")

报错:

Traceback (most recent call last):File "demo.py", line 137, in <module>main()File "demo.py", line 93, in mainmodel = get_model(cfg)File "/home/user1/pjs/frvt/deb-age/open_models/age-gender-estimation/src/factory.py", line 11, in get_modelpooling="avg"File "/home/user1/miniconda3/envs/py377/lib/python3.7/site-packages/tensorflow/python/keras/applications/efficientnet.py", line 618, in EfficientNetB3**kwargs)File "/home/user1/miniconda3/envs/py377/lib/python3.7/site-packages/tensorflow/python/keras/applications/efficientnet.py", line 406, in EfficientNetfile_hash=file_hash)File "/home/user1/miniconda3/envs/py377/lib/python3.7/site-packages/tensorflow/python/keras/utils/data_utils.py", line 282, in get_fileraise Exception(error_msg.format(origin, e.errno, e.reason))
Exception: URL fetch failure on https://storage.googleapis.com/keras-applications/efficientnetb3_notop.h5: None -- [Errno -2] Name or service not known

解决:手动下载这个模型(https://storage.googleapis.com/keras-applications/efficientnetb3_notop.h5),放到 ~/.keras/models/(也即/home/user1/.keras/models/)目录下即可。

https://blog.csdn.net/zkp_987/article/details/81590539

  相关解决方案