The issue is that I'm trying to make image recognition software in a python notebook that I shot in Google Cloud, and this is the code I wrote to check if it works. Thanks in advance.
h,w = (64,64)
#I am doing an image recognition software, but i can't get the pictures to show
new_image = Image.new('RGB',(h*15,w*10))
offset = 900
train_dir = './base_de_dades/train/images/'#cambiar por test,var y train
train_image_names = os.listdir(train_dir)
train = np.array(Image.new('RGB',(h,w)))
for file in train_image_names:
dir2 = os.path.join(train_dir,file)
if dir2 != './base_de_dades/test/images/.ipynb_checkpoints':
img = np.array(image.load_img(dir2,target_size=(h,w)))
np.append(train,img, axis = 0)
test_dir = './base_de_dades/test/images/'#cambiar por test,var y train
test_image_names = os.listdir(test_dir)
test = np.array(Image.new('RGB',(h,w)))
for file in test_image_names:
dir2 = os.path.join(test_dir,file)
if dir2 != './base_de_dades/test/images/.ipynb_checkpoints':
img = np.array(image.load_img(dir2,target_size=(h,w)))
np.append(test,img, axis = 0)
for q in range(10):
ranks_q = ranks[q*(offset+1),:]
for i in range(15):
print "nigger"
new_image.paste(Image.fromarray(train[ranks_q[i]])), (h*(1+i),w*q)
error here ^
ima_q = Image.fromarray(test[q*(offset+1),...])
ima_q = ImageOps.expand(ima_q, border=3, fill = 'green')
new_image.paste(ima_q, (0,w*q))
plt.imshow(new_image)
plt.axis('off')
plt.show()