May 2020
Beginner to intermediate
430 pages
10h 39m
English
Once a new image is uploaded, our task will be to find out which class it belongs to. To do that, we calculate the probability for each class that the image could belong to and pick the class with the highest probability. The example here illustrates a calculation using the VGG pre-trained model, but the same concept applies elsewhere:
vgg_feature = final_model.predict(img_data,verbose=0)vgg_feature_np = np.array(vgg_feature)vgg_feature1D = vgg_feature_np.flatten()print (vgg_feature1D)y_prob = final_model.predict(img_data)y_classes = y_prob.argmax(axis=-1)print (y_classes)
In the preceding code, we calculated the probability of the image belonging to a particular class using the model.predict() function ...