Spaces:
Sleeping
Sleeping
zhangjiaheng001
commited on
Commit
•
a0a12f9
1
Parent(s):
bbe469e
界面中文化
Browse files- .gitignore +1 -0
- app.py +8 -5
- class_names_chinese.txt +101 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__pycache__
|
app.py
CHANGED
@@ -8,7 +8,7 @@ from timeit import default_timer as timer
|
|
8 |
from typing import Tuple, Dict
|
9 |
|
10 |
# Setup class names
|
11 |
-
with open("
|
12 |
class_names = [food_name.strip() for food_name in f.readlines()]
|
13 |
|
14 |
### 2. Model and transforms preparation ###
|
@@ -53,8 +53,8 @@ def predict(img) -> Tuple[Dict, float]:
|
|
53 |
vit.eval()
|
54 |
with torch.inference_mode():
|
55 |
# Pass the transformed image through the model and turn the prediction logits into prediction probabilities
|
56 |
-
pred_probs = torch.softmax((effnetb2(
|
57 |
-
|
58 |
#with torch.inference_mode():
|
59 |
# Pass the transformed image through the model and turn the prediction logits into prediction probabilities
|
60 |
#pred_probs_vit = torch.softmax(vit(img), dim=1)
|
@@ -73,8 +73,11 @@ def predict(img) -> Tuple[Dict, float]:
|
|
73 |
|
74 |
# Create title, description and article strings
|
75 |
#title = "FoodVision Big 🍔👁"
|
76 |
-
description = "
|
77 |
-
|
|
|
|
|
|
|
78 |
|
79 |
title = "食品分类器 🍔👁"
|
80 |
|
|
|
8 |
from typing import Tuple, Dict
|
9 |
|
10 |
# Setup class names
|
11 |
+
with open("class_names_chinese.txt", "r") as f: # reading them in from class_names.txt
|
12 |
class_names = [food_name.strip() for food_name in f.readlines()]
|
13 |
|
14 |
### 2. Model and transforms preparation ###
|
|
|
53 |
vit.eval()
|
54 |
with torch.inference_mode():
|
55 |
# Pass the transformed image through the model and turn the prediction logits into prediction probabilities
|
56 |
+
pred_probs = torch.softmax((effnetb2(img_effnetb2)+vit(img_vit))/2, dim=1)
|
57 |
+
|
58 |
#with torch.inference_mode():
|
59 |
# Pass the transformed image through the model and turn the prediction logits into prediction probabilities
|
60 |
#pred_probs_vit = torch.softmax(vit(img), dim=1)
|
|
|
73 |
|
74 |
# Create title, description and article strings
|
75 |
#title = "FoodVision Big 🍔👁"
|
76 |
+
description = "训练集使用的food101数据集,其中包含101种不同类型食品,\
|
77 |
+
[原项目](https://www.learnpytorch.io/09_pytorch_model_deployment/)在测试集上的精度大约为60%,\
|
78 |
+
我这边主要简单的替换了其中的分类模型,使得精度提到80%以上,同时也进了中文化处理,\
|
79 |
+
注意此分类器只包含了101个品种的食物,如披萨,饺子,炸薯条,炒饭,巧克力慕斯等等,[详细品类详见此处](class_names_chinese.txt)."
|
80 |
+
article = "Created at [09. PyTorch Model Deployment]."
|
81 |
|
82 |
title = "食品分类器 🍔👁"
|
83 |
|
class_names_chinese.txt
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
大蒜面包
|
48 |
+
汤团
|
49 |
+
希腊式沙拉
|
50 |
+
烤奶酪三明治
|
51 |
+
烤三文鱼
|
52 |
+
鳄梨
|
53 |
+
饺子
|
54 |
+
汉堡包
|
55 |
+
酸辣汤
|
56 |
+
热狗
|
57 |
+
墨西哥煎蛋
|
58 |
+
鹰嘴豆泥
|
59 |
+
冰淇淋
|
60 |
+
烤宽面条
|
61 |
+
龙虾浓汤
|
62 |
+
龙虾卷三明治
|
63 |
+
通心粉和奶酪
|
64 |
+
马卡龙
|
65 |
+
味噌汤
|
66 |
+
青口贝
|
67 |
+
玉米片
|
68 |
+
煎蛋卷
|
69 |
+
洋葱圈
|
70 |
+
生蚝
|
71 |
+
泰语垫
|
72 |
+
西班牙海鲜饭
|
73 |
+
薄煎饼
|
74 |
+
意式奶冻
|
75 |
+
北京烤鸭
|
76 |
+
河粉
|
77 |
+
比萨
|
78 |
+
猪排
|
79 |
+
肉汁奶酪薯条
|
80 |
+
牛排
|
81 |
+
拉猪肉三明治
|
82 |
+
拉面
|
83 |
+
馄饨
|
84 |
+
红色天鹅绒蛋糕
|
85 |
+
烩饭
|
86 |
+
萨莫萨三角饺
|
87 |
+
生鱼片
|
88 |
+
扇贝
|
89 |
+
海藻沙拉
|
90 |
+
虾和粉打窝沙食
|
91 |
+
肉酱意粉
|
92 |
+
意粉培根蛋面
|
93 |
+
春卷
|
94 |
+
牛扒
|
95 |
+
草莓脆饼
|
96 |
+
寿司
|
97 |
+
炸玉米饼
|
98 |
+
章鱼烧
|
99 |
+
提拉米苏
|
100 |
+
金枪鱼鞑靼
|
101 |
+
威化饼
|