title: How to load tensorflow models using opencv
body: <p>import cv2
      import tensorflow as tf
      #i wan t
      # What model to download.
      MODEL_NAME = 'emotion'
      MODEL_FILE = MODEL_NAME + 'frozen_inference_graph.pb'
      DOWNLOAD_BASE = '<a href="http://download.tensorflow.org/models/object_detection/" rel="nofollow noreferrer">http://download.tensorflow.org/models/object_detection/</a>'</p>
  
  <pre><code># 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')
  </code></pre>
  
  <p>cv2.error: OpenCV(4.1.1) /io/opencv/modules/dnn/src/caffe/caffe_io.cpp:1121: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "graph.pbtxt" in function 'ReadProtoFromTextFile'</p>