bigyunicorn's picture
pushing the updated app.py one more time
93492fd
raw
history blame
1.8 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", "ahi(yellowfin).jpg", "bluefin.jpg", "ika(squid) sashimi.jpeg", "katsuo.jpg", "Katsuo(Bonito_Skipjack Tuna).jpg", "Maguro(Bluefin Tuna).jpg", "redsnapper.jpg", "saba.jpg", "sake.jpg", "squid.jpg", "yellowtail.jpg"]
img_examples2 = ["dalle_EngawaAndHotate.png", "dalle_Ika (squid) sashimi.png", "Dalle_Maguro(Bluefin Tuna), Katsuo(Bonito_Skipjack Tuna), Ahi(Yellowfin & Bigeye Tuna).png", "dalle_Saba.png", "Dalle_sakeSashimi.png", "stableDiffusion_sweetShrimpSashimi.jpg"]
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()