Caffe2 – Verifying Access to Pre-Trained Models
Before you learn to use a pre-trained model in your Python application, let us first verify that the models are installed on your machine and are accessible through the Python code.
When you install Caffe2, the pre-trained models are copied in the installation folder. On the machine with Anaconda installation, these models are available in the following folder.
anaconda3/lib/python3.7/site-packages/caffe2/python/models
Check out the installation folder on your machine for the presence of these models. You can try loading these models from the installation folder with the following short Python script −
CAFFE_MODELS = os.path.expanduser("/anaconda3/lib/python3.7/site-packages/caffe2/python/models") INIT_NET = os.path.join(CAFFE_MODELS, ''squeezenet'', ''init_net.pb'') PREDICT_NET = os.path.join(CAFFE_MODELS, ''squeezenet'', ''predict_net.pb'') print(INIT_NET) print(PREDICT_NET)
When the script runs successfully, you will see the following output −
/anaconda3/lib/python3.7/site-packages/caffe2/python/models/squeezenet/init_net.pb /anaconda3/lib/python3.7/site-packages/caffe2/python/models/squeezenet/predict_net.pb
This confirms that the squeezenet module is installed on your machine and is accessible to your code.
Now, you are ready to write your own Python code for image classification using Caffe2 squeezenet pre-trained module.