Spaces:
Runtime error
Runtime error
File size: 979 Bytes
e2015ee ba182c9 |
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 |
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)
|