简体   繁体   English

如何将 ssd_mobilenet_v1_COCO_2017_11_17 加载到本地的 object_detection_webcam?

[英]How can I load the ssd_mobilenet_v1_COCO_2017_11_17 to the object_detection_webcam locally?

MODEL_FILE = MODEL_NAME + '.tar.gz'
DOWNLOAD_BASE = 'http://download.tensorflow.org/models/object_detection/'

# Path to frozen detection graph.
PATH_TO_CKPT = MODEL_NAME + '/frozen_inference_graph.pb'

# List of the strings that is used to add correct label for each box.
PATH_TO_LABELS = os.path.join('data', 'mscoco_label_map.pbtxt')

NUM_CLASSES = 90


#Download Model

# you can manually download this
opener = urllib.request.URLopener()
opener.retrieve(DOWNLOAD_BASE + MODEL_FILE, MODEL_FILE)

tar_file = tarfile.open(MODEL_FILE)
for file in tar_file.getmembers():
  file_name = os.path.basename(file.name)
  if 'frozen_inference_graph.pb' in file_name:
    tar_file.extract(file, os.getcwd())

This piece of code basically downloads the ssd_mobilenet_v1_COCO_2017_11_17 model each time I run the object_detection_webcam.py.这段代码基本上是每次运行object_detection_webcam.py时下载ssd_mobilenet_v1_COCO_2017_11_17模型。

How can I run the same file without having to download ssd_mobilenet_v1_COCO_2017_11_17 each time I run the script ?如何在每次运行脚本时无需下载 ssd_mobilenet_v1_COCO_2017_11_17 即可运行相同的文件? I'm very new to working with .tar files.我对使用 .tar 文件很陌生。

Your help will be appreciated您的帮助将不胜感激

Add a check to see if the file already exists and don't download if it does添加检查以查看 文件是否已存在,如果 存在则不要下载

if not os.path.isfile(MODEL_FILE):
    # Code to download and extract goes here

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 google colab tensorflow 1.15.2 上训练自定义对象检测模型 ssd_mobilenet_v1_coco 和 ssd_inception_v2_coco? - how to train a custom object detection model ssd_mobilenet_v1_coco and ssd_inception_v2_coco on google colab tensorflow 1.15.2? 使用tensorflow时,在哪里可以找到ssd_mobilenet_v1_coco的标签映射文件(pbtxt)? - Where can I find the label map file(pbtxt) of ssd_mobilenet_v1_coco when using tensorflow? 如何在tensorflow.js上加载/重新训练/保存ssd_inception_v2_coco? - How can I load/retrain/save ssd_inception_v2_coco on tensorflow.js? 对象检测tensorflow api中的ssd mobilenet v1可以尝试使用不同于默认值的调整大小形状吗? - Can ssd mobilenet v1 in object detection tensorflow api be tried with different resize shapes than the default ones? 每10k-12k步骤使用ssd_mobilenet_v2_quantized_300x300_coco的对象检测模型的丢失增加 - Loss of Object detection model using ssd_mobilenet_v2_quantized_300x300_coco increases after every 10k-12k steps model_main.py 无法训练 mobilenet ssd v2 - tensorflow object 检测 api - model_main.py fails to traing mobilenet ssd v2 - tensorflow object detection api Tensorflow 的 pb 和 pbtxt 文件在重新训练 MobileNet SSD V1 COCO 后不适用于 OpenCV - Tensorflow' pb and pbtxt files don't work with OpenCV after retraining MobileNet SSD V1 COCO Object 检测 1080p 与 SSD Mobilenet (Tensorflow API) - Object detection in 1080p with SSD Mobilenet (Tensorflow API) Tensorflow 对象检测 API 错误:ValueError:不支持 ssd_mobil.net_v2 - Tensorflow Objct detection API error: ValueError: ssd_mobilenet_v2 is not supported 尝试添加警报以检测 model “ssd_mobilenet_v2”,引发错误 - Trying to add an alert to detection model "ssd_mobilenet_v2", throws an error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM