Spaces:
Runtime error
Runtime error
# 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) | |