bigyunicorn's picture
remove the img folder
69d1296
raw
history blame
1.38 kB
# AUTOGENERATED! DO NOT EDIT! File to edit: sashimiIdentier.ipynb.
# %% auto 0
__all__ = ['learner', 'categories', 'img_examples', 'iface', 'sashimiIentifer']
# %% sashimiIdentier.ipynb 19
from fastai.vision.all import *
import gradio as gr
# %% sashimiIdentier.ipynb 20
# first load the learner
learner = load_learner ('./sashimiModel.pkl')
# %% sashimiIdentier.ipynb 21
# combine with gradio.
categories = ['Ahi(Yellowfin & Bigeye Tuna)', 'Ebi(Sweet Shrimp/Prawns)', 'Hamachi(Yellowtail)', 'Hamadai(Red Snapper)', 'Hotate(Scallops)', 'Ika(Squid)', 'Katsuo(Bonito/Skipjack Tuna)', 'Maguro(Bluefin Tuna)', 'Saba(Japanese Mackerel)', 'Sake(Salmon)']
def sashimiIentifer(input_imgFilePath):
(pred,idx,probs) = learner.predict(input_imgFilePath)
return dict(zip(categories, map(float, probs)))
img_examples1 = ["Hotate_Scallops.jpg", "Ahi_YellowfinAndBigeyeTuna_Sashimi.jpg"]
img_examples2 = [ "dalle_EngawaAndHotate.png"]
demo = gr.Blocks()
with demo:
with gr.Row():
input = gr.inputs.Image(shape=(192,192))
output = gr.outputs.Label()
with gr.Tab("Example Images from Web"):
examplesFromBrowser = gr.Examples(examples=img_examples1, inputs=input)
with gr.Tab("Example Images generated by AI"):
examplesFromAI = gr.Examples(examples=img_examples2,inputs=input)
input.change(fn=sashimiIentifer, inputs=input, outputs=output)
demo.launch()