Cannot download model for object detection

Asked 1 years ago, Updated 1 years ago, 65 views

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())

Reference
https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb

Environment
Ubuntu 14.04 LTS
Python 2.7.6
Python 3.4.3
tensorflow 1.4.0 (CPU version)
jupyter notebook 5.2.1

python tensorflow

2022-09-30 20:24

2 Answers

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.


2022-09-30 20:24

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)

Note: https://github.com/tensorflow/models/blob/master/research/object_detection/colab_tutorials/object_detection_tutorial.ipynb


2022-09-30 20:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.