BearDemo / app.py
22GNUs's picture
Finish bear classify
9a29c3e
raw
history blame contribute delete
565 Bytes
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import gradio as gr
from fastai.vision.all import load_learner
# In[33]:
# In[4]:
learner = load_learner("export.pkl")
# In[46]:
categories = ["black", "grizzly", "teddy"]
def image_classifier(img):
pred, idx, probs = learner.predict(img)
return dict(zip(categories, map(float, probs)))
# In[47]:
# In[48]:
intf = gr.Interface(
fn=image_classifier,
inputs="image",
outputs="label",
examples=["black.jpg", "grizzly.jpg", "teddy.jpg"],
)
intf.launch()
# ## Export
# In[ ]: