AgastyaPatel's picture
Trained Model based on Resnet34
01fe673
raw
history blame contribute delete
837 Bytes
# AUTOGENERATED! DO NOT EDIT! File to edit: Deployment.ipynb.
# %% auto 0
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'inf', 'classify_image']
# %% Deployment.ipynb 2
#importing dependencies
from fastai.vision.all import *
import gradio as gr
# %% Deployment.ipynb 3
#creating inference
learn = load_learner('models/resnet34_glr_pokemon.pkl')
# %% Deployment.ipynb 4
categories = learn.dls.vocab
def classify_image(image):
pred, idx, probs = learn.predict(image)
return dict(zip(categories, map(float, probs)))
categories
# %% Deployment.ipynb 5
#gradio interface
image = gr.Image()
label = gr.Label()
examples = ['TestInputs/01.jpg', 'TestInputs/02.jpg', 'TestInputs/03.png', 'TestInputs/04.png']
inf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples).launch()