File size: 844 Bytes
e51fbdb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: -all
# custom_cell_magics: kql
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.11.2
# kernelspec:
# display_name: Python 3.9.14 64-bit
# language: python
# name: python3
# ---
# %%
from fastai.vision.all import *
# %%
learn = load_learner("model.pkl")
# %%
categories = ("Bird", "Forest")
# %%
def classify_image(img):
pred,idx,probs = learn.predict(img)
print(probs)
print(*map(float,probs))
print(*zip(categories, map(float,probs)))
print(dict(zip(categories, map(float,probs))))
return dict(zip(categories, map(float,probs)))
# %% [markdown]
#
# im = PILImage.create("bird.jpg")
# im.to_thumb(256, 256)
# im
# %% [markdown]
# classify_image(im)
|