Let's go through all the learning with minist and do it with your favorite image! Error that occurred just before I thought (probably Mac only)
deep_learning_test.py
train_img_dirs = ['T','F']
train_image = []
train_label = []
for i, d in enumerate(train_img_dirs):
# ./data/Get the file name in each of the following directories
files = os.listdir('./data/' + d)
for f in files:
#Image loading
img = cv2.imread('./data/' + d + '/' + f)
img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
#One side is IMG_Resize to SIZE square
img = cv2.resize(img, (IMG_SIZE, IMG_SIZE))
#In a row
img = img.flatten().astype(np.float32)/255.0
train_image.append(img)
# one_hot_Create a vector and add it as a label
tmp = np.zeros(NUM_CLASSES)
tmp[i] = 1
train_label.append(tmp)
When I compile this ...
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in ipp_cvtColor
Fall into. why
https://stackoverflow.com/questions/20822288/python-opencv-cv2-opencv-error-assertion-failed-scn-3-scn-4-in-unkno according to When I try to print (img.shape) and the result is None type, it seems that the image cannot be read correctly. So if you do print (d) and print (f) and display the loaded directories and files
$ T
$ .DS_Store
Came out. The directory was read correctly, but the file contains an example. It wasn't running well because .DS_Store was loaded.
What is .DS_Store A hidden file for recording metadata about folder display settings such as icon position and display settings. A .DS_Store file has been created in every folder you access, both in the Finder and on the remote system.
Delete .DS_Store in separate directory
find Desktop/Target directory-name ".DS_Store" -print -exec rm {} ";"
Delete all
sudo find / -name ".DS_Store" -delete
Will not be created in the future
defaults write com.apple.desktopservices DSDontWriteNetworkStores True
Also, you can easily erase it with an app called MacForkCleaner.
At the first OpenCV, I struggled quite a bit, wondering if the writing style or image format was wrong. (I can't find it at all even if I check it) Please refer to those who have fallen into the same phenomenon using MacOS. Since .DS_Store is a hidden file, I didn't realize that I was looking at Pat. Do other people notice it through experience?
Delete .DS_Store from mac http://qiita.com/supersnack/items/157b69589e36f340bb29 How .DS_Store works and how to set it not to delete & create http://uxmilk.jp/48160 Python-OpenCV cv2 OpenCV Error: Assertion failed (scn == 3 || scn == 4) in unknown function, file ......\modules\imgproc\src\color.cpp https://stackoverflow.com/questions/20822288/python-opencv-cv2-opencv-error-assertion-failed-scn-3-scn-4-in-unkno
Recommended Posts