Sort UTKFace datasets by the following features. ·no problem ·grayscale ・ Multiple people are shown ・ Processed
Use Last created learning model to identify the image data in the part1 folder of the UTK Face dataset one by one. ↓ Create the following folder in Google My Drive and save the identified image ・ Normal ・ Grayscale ・ Several ・ Processing
Google Colaboratory(GPU)
#UTKFace part1 ZIP read
z = zipfile.ZipFile('/content/drive/My Drive/part1.zip')
imgfiles = [ x for x in z.namelist() if re.search(r"^part1.*jpg$", x)]
for imgfile in imgfiles:
image = Image.open(io.BytesIO(z.read(imgfile)))
image = image.convert('RGB')
image_p1 = image.resize((im_size, im_size))
data = np.asarray(image_p1)
#shape(299,299,3)→(1,299,299,3)Change to
data = data[None, ...]
#Get the file name saved in the ZIP folder
file = str(os.path.basename(imgfile))
#Predict by inputting data for one image into the trained model
pred=model.predict(data)
#Change the location to save the image data according to the determined value
if np.argmax(pred) == 0:
image.save('/content/drive/My Drive/normal/' + file)
elif np.argmax(pred) == 1:
image.save('/content/drive/My Drive/grayscale/' + file)
elif np.argmax(pred) == 2:
image.save('/content/drive/My Drive/several/' + file)
else :
image.save('/content/drive/My Drive/processing/' + file)
z.close()
del z, imgfiles
Since model.predict assumes reading of multiple images (model arguments are 4D), an error occurred when trying to predict one by one. He predicted that data = data [None, ...] would convert from 3D to 4D. The image file name is not changed and is sorted and saved in each folder.
(I put a screenshot on it, but I deleted it because I thought it might be illegal.)
You can see some colored images here and there, but it seems that you can almost distinguish them.
I was learning with images showing multiple people, but probably because there was little learning data, I feel that images with stuffed animals and animals, or images with a non-simple background are also in this folder. I did.
It is possible to almost distinguish data that has characters on the face or a swirl-like pattern.
Although the discrimination accuracy is uneven, I was able to collect neat images in the normal folder. I will use this normal folder to create a model that can identify age and gender.