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

這段代碼基本上是每次運行object_detection_webcam.py時下載ssd_mobilenet_v1_COCO_2017_11_17模型。

如何在每次運行腳本時無需下載 ssd_mobilenet_v1_COCO_2017_11_17 即可運行相同的文件? 我對使用 .tar 文件很陌生。

您的幫助將不勝感激

添加檢查以查看 文件是否已存在,如果 存在則不要下載

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM