Need urgent help

Okay would you please tell me what to do to show result = No snake present in the picture.
Lyk if the probability distribution is less than 50% it will show no snake present in the picture???
I need help regarding this.

Not sure if this is what you are looking for here is an example of how to use probabilities when getting predictions:

def dog_cat(img_path):

img = open_image(img_path)

prediction, indice, losses = learn.predict(img)

#Calculate propabilities
preds_sorted, idxs = losses.sort(descending=True)
pred_1_prob = np.round(100*preds_sorted[0].item(),2)

if pred_1_prob <= 90:
    result = (f' Model IS NOT Confident: Highest Probability: ({pred_1_prob}%)')
    img.show()
else:
    result = (f' Model IS confident: ({pred_1_prob}%) Prediction: {prediction}')
    img.show()

return result

Bear in mind though that you can still get inaccurate predictions as shown in the notebook

You can access the notebook here: https://github.com/asvcode/fastai_resources/blob/master/Dog_Cat_Probabilites.ipynb

1 Like