File size: 565 Bytes
9a29c3e
 
 
 
 
 
def61cb
 
9a29c3e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
def61cb
9a29c3e
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
44
45
46
47
48
#!/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[ ]: