leigang's picture
Update app.py
ba182c9
raw
history blame contribute delete
979 Bytes
import os
os.system("hub install food_classification==1.0.0")
import gradio as gr
import cv2
import paddlehub as hub
classifier = hub.Module(name="food_classification")
def inference(img):
result = classifier.predict(images=[cv2.imread(img)])
category = str(result[0][0]['category'])
score = str(result[0][0]['score'])
res = {category: score}
print(res)
return res
title = "food_classification"
description = "美食分类(food_classification),该模型可识别苹果派,小排骨,烤面包,牛肉馅饼,牛肉鞑靼。该PaddleHub Module支持API预测及命令行预测。 "
examples = [['apple_pie.jpg'], ['baby_back_ribs.jpg'], ['baklava.jpg'], ['beef_carpaccio.jpg'], ['beef_tartare.jpg']]
interface = gr.Interface(inference, gr.inputs.Image(type="filepath"), "label", title=title, description=description,
examples=examples)
interface.launch(inbrowser=True, inline=False, share=False, enable_queue=True)