Spaces:
Runtime error
Runtime error
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb. | |
# %% auto 0 | |
__all__ = [] | |
# %% app.ipynb 5 | |
!pip install -Uqq fastai | |
from fastai.vision.all import * | |
import gradio as gr | |
def greet(name): | |
return "Hello " + name + "!!" | |
def classify_image(img): | |
pred, idx, probs = learn.predict(img) | |
return { | |
price: str(prices[pred]) + ' baht (' + pred + ")", | |
label: dict(zip(learn.dls.vocab, map(float, probs))), | |
} | |
learn = load_learner(path + 'model.pkl') | |
prices = { | |
'ฟอกกี้': 20, | |
'ฝาชี': 30, | |
} | |
# %% app.ipynb 8 | |
with gr.Blocks() as demo: | |
gr.Markdown("Use your camera or image to get price!!!") | |
with gr.Row(): | |
with gr.Column(): | |
image_input = gr.Image(source='webcam') | |
price_btn = gr.Button("PRICE") | |
image_input2 = gr.Image() | |
price_btn2 = gr.Button("PRICE") | |
with gr.Column(): | |
price = gr.Textbox(label="ITEM PRICE") | |
label = gr.Label() | |
price_btn.click(classify_image, inputs=image_input, outputs=[price, label]) | |
price_btn2.click(classify_image, inputs=image_input2, outputs=[price, label]) | |
demo.launch(debug=True, share=True) | |