cstorm125's picture
Update app.py
d626a43
import gradio as gr
from fastai.vision.all import *
import skimage
learn = load_learner('export.pkl')
labels = [
"แกงเขียวหวานไก่","แกงเทโพ","แกงเลียง","แกงจืดเต้าหู้หมูสับ","แกงจืดมะระยัดไส้",
"แกงมัสมั่นไก่","แกงส้มกุ้ง","ไก่ผัดเม็ดมะม่วงหิมพานต์","ไข่เจียว","ไข่ดาว",
"ไข่พะโล้","ไข่ลูกเขย","กล้วยบวชชี","ก๋วยเตี๋ยวคั่วไก่","กะหล่ำปลีผัดน้ำปลา",
"กุ้งแม่น้ำเผา","กุ้งอบวุ้นเส้น","ขนมครก","ข้าวเหนียวมะม่วง","ข้าวขาหมู",
"ข้าวคลุกกะปิ","ข้าวซอยไก่","ข้าวผัด","ข้าวผัดกุ้ง","ข้าวมันไก่",
"ข้าวหมกไก่","ต้มข่าไก่","ต้มยำกุ้ง","ทอดมัน","ปอเปี๊ยะทอด",
"ผักบุ้งไฟแดง","ผัดไท","ผัดกะเพรา","ผัดซีอิ๊วเส้นใหญ่","ผัดฟักทองใส่ไข่",
"ผัดมะเขือยาวหมูสับ","ผัดหอยลาย","ฝอยทอง","พะแนงไก่","ยำถั่วพู",
"ยำวุ้นเส้น","ลาบหมู","สังขยาฟักทอง","สาคูไส้หมู","ส้มตำ","หมูปิ้ง","หมูสะเต๊ะ","ห่อหมก"
]
def predict(img):
img = PILImage.create(img)
pred,pred_idx,probs = learn.predict(img)
return {labels[i]: float(probs[i]) for i in range(len(labels))}
title = "Foodydudy Thai Food Classifier"
description = "A 48-class Thai food classifier using model created by @gemmythegeek (AIB 2021). Created as a demo for Gradio and HuggingFace Spaces."
article="<p style='text-align: center'><a href='https://gemmythegeek.medium.com/overcome-your-fear-for-thai-food-with-foody-dudy-7ff6d7702b22' target='_blank'>Blog post</a></p>"
examples = ['padthai.jpg','panaeng.jpg','massaman.jpg']
interpretation='default'
enable_queue=True
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()