“leigangblog” commited on
Commit
e2015ee
1 Parent(s): 834e533

Add application file

Browse files
Files changed (7) hide show
  1. app.py +24 -0
  2. apple_pie.jpg +0 -0
  3. baby_back_ribs.jpg +0 -0
  4. baklava.jpg +0 -0
  5. beef_carpaccio.jpg +0 -0
  6. beef_tartare.jpg +0 -0
  7. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ os.system("hub install food_classification==1.0.0")
3
+ import gradio as gr
4
+ import cv2
5
+ import paddlehub as hub
6
+
7
+ classifier = hub.Module(name="food_classification")
8
+
9
+
10
+ def inference(img):
11
+ result = classifier.predict(images=[cv2.imread(img)])
12
+ category = str(result[0][0]['category'])
13
+ score = str(result[0][0]['score'])
14
+ res = {category: score}
15
+ print(res)
16
+ return res
17
+
18
+
19
+ title = "food_classification"
20
+ description = "美食分类(food_classification),该模型可识别苹果派,小排骨,烤面包,牛肉馅饼,牛肉鞑靼。该PaddleHub Module支持API预测及命令行预测。 "
21
+ examples = [['apple_pie.jpg'], ['baby_back_ribs.jpg'], ['baklava.jpg'], ['beef_carpaccio.jpg'], ['beef_tartare.jpg']]
22
+ interface = gr.Interface(inference, gr.inputs.Image(type="filepath"), "label", title=title, description=description,
23
+ examples=examples)
24
+ interface.launch(inbrowser=True, inline=False, share=True, enable_queue=True)
apple_pie.jpg ADDED
baby_back_ribs.jpg ADDED
baklava.jpg ADDED
beef_carpaccio.jpg ADDED
beef_tartare.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ paddlepaddle
2
+ paddlehub
3
+ chardet