Caffe2 - Verifying Access to Pre-Trained Models



Before you learn to use a pre-trained model in your Python application, let us initially 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 duplicated 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

Look at 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 open to your code.

Presently, you are prepared to compose your own Python code for picture classification using Caffe2 squeezenet pre-trained module.





Input your Topic Name and press Enter.