-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
27 lines (19 loc) · 707 Bytes
/
app.py
File metadata and controls
27 lines (19 loc) · 707 Bytes
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
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
# %% auto 0
__all__ = ['path', 'learn', 'categories', 'examples', 'intf', 'classify_image']
# %% app.ipynb 0
from fastai.vision.all import PILImage, load_learner
import gradio as gr
import pathlib
path = pathlib.Path().absolute()
# %% app.ipynb 2
learn = load_learner(path/'model.pkl')
# %% app.ipynb 4
categories = learn.dls.vocab
def classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float,probs)))
# %% app.ipynb 6
examples = ['sample.png']
intf = gr.Interface(fn=classify_image, inputs="image", outputs="label", examples=examples, allow_flagging="never")
intf.launch(inline=False, share=True)