When I tried to compare photos A and B, I noticed that "Oh, I divided them into folders." I steadily looked at the photos from one folder and divided them into folders ... I tried it as a trigger. By the way, I was trapped when I processed the image, so I will go with it.
"Isn't it better to increase the chord atmosphere?" I was able to do it if I proceeded with a feeling like that. A man who does not study as usual.
dog_and_cat.py
#I tried to fully merge Jupyter Notebook cells
import os
import glob
import matplotlib.pyplot as plt
from PIL import Image
from google.colab import drive
# GoogleDrive_Mount
drive.mount('/content/drive')
#Specify the data storage folder
input_dir="/content/drive/My Drive/Colab Notebooks/test/Photos"
dirs = glob.glob(input_dir + '/*.jpg')
input_dir2="/content/drive/My Drive/Colab Notebooks/test/Photos2"
dirs2 = glob.glob(input_dir2 + '/*.jpg')
#Check if you can refer
print(dirs)
print(dirs2)
#Add the length of the list and check the number of displayed sheets
hs = len(dirs)+len(dirs2)
print(hs)
#Display settings
col=5
row=hs/col
cols=col*3
rows=row*4
dpis = 100
#Image display size and resolution
fig = plt.figure(figsize=(cols,rows),dpi=dpis)
#** Third designation
pi=1
#Image display
for img,img2 in zip(dirs,dirs2):
#1st stage
plot_num = pi
ax=fig.add_subplot(row, col, plot_num)
ac=os.path.basename(img)
ax.set_title(ac)
img = Image.open(img)
plt.imshow(img, cmap='gray')
#2nd stage
plot_num2 = pi+5
bx=fig.add_subplot(row, col, plot_num2)
bc=os.path.basename(img2)
bx.set_title(bc)
img2 = Image.open(img2)
plt.imshow(img2, cmap='gray')
pi = pi+1
Well, it's cute. But the sizes are different.
Under "img = Image.open (img)" and "img2 = Image.open (img2)" Try to put each (for the time being, put 200 in the number)
img = img.resize((200, 200))
img2 = img2.resize((200, 200))
Everyone was safe. good for you.
Expect graying by adding the following to the above code
img = img.convert("L")
img2 = img2.convert("L")
Something different from the image ... It seems that I have to do this further if I think. Unconscious. (There was a place where I wrote something that could be done with just this.)
plt.imshow(img, cmap='gray')
plt.imshow(img2, cmap='gray')
In the future, we have to output features and extract similar images. It seems difficult, but it's really fun to be able to learn again.
Teka, I noticed that there is a little "A" in the image Dassa wwww I won't fix it, but w
Recommended Posts