Ask the Tensorflow API Quick Start question.
When I was running on Jupiter notebook, the following error occurred when I downloaded the model.If you know how to solve this problem, please let me know.
Thank you.
(This is my first post, so I may not be able to ask you questions.I'm sorry.)
Error
IOError
Traceback (most recent call last) <ipython-input-7-f921d2932261>in<module>()
1 opener = urllib.request.URLopener()
---->2owner.retrieve (DOWNLOAD_BASE + MODEL_FILE, MODEL_FILE)
3 tar_file=tarfile.open(MODEL_FILE)
4 for file intar_file.getmembers():
5 file_name = os.path.basename (file.name)
/usr/lib/python 2.7/urllib.pyc in retrieve (self, url, filename, reporthook, data)
242 heads=fp.info()
243 if filename:
-->244 tfp=open(filename, 'wb')
245 else:
246 import tempfile
IOError: [Errno13] Permission denied: 'ssd_mobilenet_v1_coco_2017_11_17.tar.gz'
Source Code
oper=urllib.request.URLopener()
owner.retrieve (DOWNLOAD_BASE + MODEL_FILE, MODEL_FILE)
tar_file=tarfile.open(MODEL_FILE)
for file intar_file.getmembers():
file_name =os.path.basename (file.name)
if'frozen_inference_graph.pb'in file_name:
tar_file.extract(file,os.getcwd())
Environment
Ubuntu 14.04 LTS
Python 2.7.6
Python 3.4.3
tensorflow 1.4.0 (CPU version)
jupyter notebook 5.2.1
When I was trying to find out why I couldn't oppener.retrieve
in Python, I noticed that the directory didn't have permissions.
This post was posted as a community wiki based on @bluekye62's comments.
As of November 18, 2020, we have confirmed that it can be done in the following ways:
import tensorflow as tf
import pathlib
defload_model(model_name):
base_url='http://download.tensorflow.org/models/object_detection/'
model_file=model_name+'.tar.gz'
model_dir=tf.keras.utils.get_file(
fname = model_name,
origin=base_url+model_file,
untar=True)
model_dir=pathlib.Path(model_dir)/"saved_model"
model=tf.saved_model.load(str(model_dir))
return model
model_name ='ssd_mobilenet_v1_coco_2017_11_17'
detection_model=load_model(model_name)
911 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
581 PHP ssh2_scp_send fails to send files as intended
578 Understanding How to Configure Google API Key
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.