Add script for model inference

This commit is contained in:
moshferatu 2024-05-09 05:23:58 -07:00
parent 2d28f7811f
commit 611cb19740
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import os
from fastai.learner import load_learner
from pathlib import Path
path = Path(os.path.dirname(os.path.realpath(__file__)))
# Make sure to export the model first via the notebook.
# The exported model is not included in the repository.
model = load_learner(path/'export.pkl')
prediction, index, probabilities = model.predict(path/'test-images/grizzly.jpg')
print(f'Prediction: {prediction}, Probability: {probabilities[index]:0.4f}')

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB