diff --git a/practical-deep-learning-for-coders/lesson-2/predict.py b/practical-deep-learning-for-coders/lesson-2/predict.py new file mode 100644 index 0000000..7ce516e --- /dev/null +++ b/practical-deep-learning-for-coders/lesson-2/predict.py @@ -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}') \ No newline at end of file diff --git a/practical-deep-learning-for-coders/lesson-2/test-images/grizzly.jpg b/practical-deep-learning-for-coders/lesson-2/test-images/grizzly.jpg new file mode 100644 index 0000000..5373886 Binary files /dev/null and b/practical-deep-learning-for-coders/lesson-2/test-images/grizzly.jpg differ