catsvsdogs / test.py
notentered's picture
Prototype 1 ready
c5311ab
raw
history blame contribute delete
341 Bytes
from fastai.vision.all import *
import sys
learn = load_learner("model.pkl")
img_path = sys.argv[1]
img = PILImage.create(img_path)
pred, pred_idx, probs = learn.predict(img)
print("\nPrediction:", pred)
print("Index:", pred_idx)
print("\nProbabilities:")
for label, p in zip(learn.dls.vocab, probs):
print(f"{label} {float(p):.4f}")