-2
$\begingroup$

I am building a facial recognition system. The model is complete but I am having minor issues during prediction. I used the Image data generator to load images from train and test folders and trained the CNN with 98% accuracy. However, when I predict the images, instead of labels, logits are being displayed. I tried the manual method of assigning labels to each logit, but that appears to be a tedious task and requires more time to be processed.

E.g., what is being displayed is:

[[1 0 0]]

What I need is:

recognized person is "steve rogers".
$\endgroup$
0
$\begingroup$

As you are trying to solve Facial Recognition problem the best approach is to use Siemese Network or Triplet Loss type Network.

But to answer your question in case of Facial Recognition problem as a classification problem you need to sort your categories according to alphabetically order & map it to your one hot encoded output values to it.

For proper implementation of Facial Recognition software watch following playlist https://www.youtube.com/playlist?list=PLkDaE6sCZn6Gl29AoE31iwdVwSG-KnDzF

$\endgroup$
0
$\begingroup$
datagen = ImageDataGenerator()
datagen.fit(X)
trainData = datagen.flow_from_directory(...)
LABELS= trainData.class_indices.keys()
pred = model.predict([image_data])[0] # For first image!
print("Detected :", LABELS[np.argmax(pred)] )

The array of 0 and 1 is the prediction metrics.

You need a list of label arranged in same manner as your output layer. So that the column with highest probability (in your case 1st column with probability 1).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.