The problem of io loading .mat data and imread reading pictures under Scipy
When we need to load MATLAB’s .mat file, if we use:
import scipy.misc
import scipy.io
import os
cwd = os.getcwd()
data = scipy.io.loadmat(cwd + "/data/imagenet-vgg-verydeep-19.mat")
Will report an error:
AttributeError: module’scipy’ has no attribute’io’
The reason for this may be that the submodules under scipy cannot be imported directly.
from scipy import io
Finally changed to:
import scipy.misc
from scipy import io
import os
cwd = os.getcwd()
data = io.loadmat(cwd + "/data/imagenet-vgg-verydeep-19.mat")
problem solved.
Also use the imread function under Scipy.misc,
import scipy.misc
cwd = os.getcwd()
VGG_PATH = cwd + "/data/imagenet-vgg-verydeep-19.mat"
IMG_PATH = cwd + "/data/cat.jpg"
input_image = imread(IMG_PATH)
appear:
AttributeError : ‘module’ object has no attribute’imread ‘
This is sometimes because you do not have pillow dependency packages
pip install pillow
This is how I solved it.