Spaces:
Runtime error
Runtime error
File size: 1,126 Bytes
ef43caa da9fd8c ef43caa da9fd8c ef43caa 5e4fb43 ef43caa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 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)
|