[英]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.