导入cv2 将tensorflow作为tf导入 #我想要 #要下载什么型号。 MODEL_NAME ='情感' MODEL_FILE = MODEL_NAME +'frozen_inference_graph.pb' DOWNLOAD_BASE =''
# Path to frozen detection graph. This is the actual model that is used for the object detection.
# PATH_TO_CKPT = MODEL_NAME + '/frozen_inference_graph.pb'
PATH_TO_CKPT = 'age/frozen_inference_graph.pb'
# List of the strings that is used to add correct label for each box.
PATH_TO_LABELS1 = os.path.join('data', 'gender.pbtxt')
PATH_TO_LABELS2 = os.path.join('data', 'age.pbtxt')
NUM_CLASSES1 = 2
NUM_CLASSES2 = 7
# ## Download Model
# if not os.path.exists(MODEL_NAME + '/frozen_inference_graph.pb'):
if not os.path.exists('screwdriver_graph/frozen_inference_graph.pb'):
print('Downloading the model')
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())
print('Download complete')
cv2.error:OpenCV(4.1.1)/io/opencv/modules/dnn/src/caffe/caffe_io.cpp:1121:error:(-2:Unspecified error)FAILED:fs.is_open()。无法在函数“ ReadProtoFromTextFile”中打开“ graph.pbtxt”