I am working on Caffe framework and using PyCaffe interface. I am using a Python script obtained from converting the IPython Notebook 00-classification.ipynb for testing the classification by a trained model for ImageNet. But any get_ipython() statement in the script is giving the following error:
$ python python/my_test_imagenet.py
Traceback (most recent call last):
File "python/my_test_imagenet.py", line 23, in <module>
get_ipython().magic(u'matplotlib inline')
In the script, I'm importing the following:
import numpy as np
import matplotlib.pyplot as plt
get_ipython().magic(u'matplotlib inline')
# Make sure that caffe is on the python path:
caffe_root = '/path/to/caffe/'
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe
plt.rcParams['figure.figsize'] = (10, 10)
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'
import os
# ... Rest of the code...
Can someone please help me to resolve this error?
You have to run your script with ipython:
$ ipython python/my_test_imagenet.py
Then get_ipython
will be already in global context.
Note: Importing it via from IPython import get_ipython
in ordinary shell python
will not work as you really need ipython
running.