zhangjiaheng001 commited on
Commit
36b2d40
1 Parent(s): fbadc07

内容修整

Browse files
Files changed (2) hide show
  1. app.py +18 -7
  2. class_names_chinese.txt +2 -2
app.py CHANGED
@@ -8,9 +8,16 @@ from timeit import default_timer as timer
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 ###
15
 
16
  # Create model
@@ -73,11 +80,15 @@ def predict(img) -> Tuple[Dict, float]:
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个品种的食物,如披萨,饺子,炸薯条,炒饭,巧克力慕斯等等,[详细品类详见此处](https://huggingface.co/spaces/john000z/foodvision_assum/blob/main/class_names_chinese.txt)."
80
- article = "Created at [09. PyTorch Model Deployment]."
 
 
 
 
81
 
82
  title = "食品分类器 🍔👁"
83
 
 
8
  from typing import Tuple, Dict
9
 
10
  # Setup class names
11
+
12
+ with open("class_names.txt", "r") as f: # reading them in from class_names.txt
13
+ class_names_0= [food_name.strip() for food_name in f.readlines()]
14
+
15
  with open("class_names_chinese.txt", "r") as f: # reading them in from class_names.txt
16
+ class_names_1 = [food_name.strip() for food_name in f.readlines()]
17
+
18
+ class_names=[]
19
+ for _ in range(len(class_names_0)):
20
+ class_names.append(class_names_0[_]+', '+class_names_1[_])
21
  ### 2. Model and transforms preparation ###
22
 
23
  # Create model
 
80
 
81
  # Create title, description and article strings
82
  #title = "FoodVision Big 🍔👁"
83
+ description = "分类器使用的训练数据的是food101数据集,其中包含101种不同类型食品,\
84
+ 如披萨,饺子,炸薯条,炒饭,巧克力慕斯等,\
85
+ 每种类别各100张训练图片\
86
+ [详细品类列表详见此处](https://huggingface.co/spaces/john000z/foodvision_assum/blob/main/class_names_chinese.txt). \
87
+ 大家可以根据**品类列表**从网上寻找对应的图片进行识别"
88
+
89
+
90
+ article = "[原项目](https://www.learnpytorch.io/09_pytorch_model_deployment/)在测试集上的精度大约为60%,\
91
+ 我这边替换了其中的模型并重新训练了数据,使得精度提到80%以上,同时也对界面进了中文化处理"
92
 
93
  title = "食品分类器 🍔👁"
94
 
class_names_chinese.txt CHANGED
@@ -1,6 +1,6 @@
1
  苹果派
2
  小排骨
3
- 巴卡拉
4
  生牛肉片
5
  鞑靼牛肉
6
  甜菜沙拉
@@ -8,7 +8,7 @@
8
  拌饭
9
  面包布丁
10
  早餐卷饼
11
- 布鲁斯凯塔
12
  凯撒沙拉
13
  香炸奶酪卷
14
  卡普雷塞沙拉
 
1
  苹果派
2
  小排骨
3
+ 巴克拉瓦
4
  生牛肉片
5
  鞑靼牛肉
6
  甜菜沙拉
 
8
  拌饭
9
  面包布丁
10
  早餐卷饼
11
+ 意式烤面包
12
  凯撒沙拉
13
  香炸奶酪卷
14
  卡普雷塞沙拉