Add script for model inference
This commit is contained in:
parent
2d28f7811f
commit
611cb19740
12
practical-deep-learning-for-coders/lesson-2/predict.py
Normal file
12
practical-deep-learning-for-coders/lesson-2/predict.py
Normal 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 |
Loading…
Reference in New Issue
Block a user