File size: 1,216 Bytes
0340ddc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91d397b
 
 
 
0340ddc
 
 
 
 
 
 
 
 
 
 
 
 
f37bc90
01c1781
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
# AUTOGENERATED! DO NOT EDIT! File to edit: chickli.ipynb.

# %% auto 0
__all__ = ['temp', 'learn', 'breeds', 'image', 'label', 'examples', 'intf', 'classify_image']

# %% chickli.ipynb 2
#!pip install fastbook
import fastbook
from fastbook import *
#!pip install fastai
from fastai.vision.widgets import *
#!pip install gradio
import gradio as gr

import IPython
from IPython.display import display
from PIL import Image

def search_images(term, max_images=50):
    print(f"Searching for '{term}'")
    return search_images_ddg(term, max_images)

# %% chickli.ipynb 3
import pathlib
#temp = pathlib.PosixPath
#pathlib.PosixPath = pathlib.WindowsPath
plt = platform.system()
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath

learn = load_learner('model.pkl')

breeds = ('Labrador Retrievers','German Shepherds','Golden Retrievers','French Bulldogs','Bulldogs','Beagles','Poodles','Rottweilers','Chihuahua')

def classify_image(img):
    pred,idx,probs = learn.predict(img)
    #return dict(zip(breeds, map(float,probs)))
    return "This is " + pred

image = gr.components.Image()
label = gr.components.Label()

intf = gr.Interface(fn=classify_image, inputs=image, outputs=label)
intf.launch(inline=False)