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())
[这段代码基本上每次我运行object_detection_webcam.py时都会下载ssd_mobilenet_v1_COCO_2017_11_17模型。
[我如何运行同一文件,而不必每次运行脚本时都下载ssd_mobilenet_v1_COCO_2017_11_17?我对使用.tar文件很陌生。
您的帮助将不胜感激
添加检查以查看file already exists,如果下载则不下载
if not os.path.isfile(MODEL_FILE):
# Code to download and extract goes here