Spaces:
Running
Running
TheEeeeLin
commited on
Commit
•
72049af
1
Parent(s):
5ea080f
feat: update more size
Browse files- app.py +6 -8
- data_utils.py +18 -0
- size_list_CN.csv +16 -0
app.py
CHANGED
@@ -6,14 +6,12 @@ from src.layoutCreate import generate_layout_photo, generate_layout_image
|
|
6 |
import pathlib
|
7 |
import numpy as np
|
8 |
from image_utils import resize_image_to_kb
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
size_list_dict = {
|
11 |
-
"一寸": (413, 295),
|
12 |
-
"二寸": (626, 413),
|
13 |
-
"教师资格证": (413, 295),
|
14 |
-
"国家公务员考试": (413, 295),
|
15 |
-
"初级会计考试": (413, 295),
|
16 |
-
}
|
17 |
color_list_dict = {
|
18 |
"蓝色": (86, 140, 212),
|
19 |
"白色": (255, 255, 255),
|
@@ -233,7 +231,7 @@ if __name__ == "__main__":
|
|
233 |
sess = onnxruntime.InferenceSession(HY_HUMAN_MATTING_WEIGHTS_PATH)
|
234 |
|
235 |
size_mode = ["尺寸列表", "只换底", "自定义尺寸"]
|
236 |
-
size_list =
|
237 |
colors = ["蓝色", "白色", "红色", "自定义底色"]
|
238 |
render = ["纯色", "上下渐变(白)", "中心渐变(白)"]
|
239 |
image_kb = ["不设置", "自定义"]
|
|
|
6 |
import pathlib
|
7 |
import numpy as np
|
8 |
from image_utils import resize_image_to_kb
|
9 |
+
from data_utils import csv_to_size_list
|
10 |
+
|
11 |
+
# 获取尺寸列表
|
12 |
+
size_list_dict = csv_to_size_list("size_list_CN.csv")
|
13 |
+
print(size_list_dict)
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
color_list_dict = {
|
16 |
"蓝色": (86, 140, 212),
|
17 |
"白色": (255, 255, 255),
|
|
|
231 |
sess = onnxruntime.InferenceSession(HY_HUMAN_MATTING_WEIGHTS_PATH)
|
232 |
|
233 |
size_mode = ["尺寸列表", "只换底", "自定义尺寸"]
|
234 |
+
size_list = list(size_list_dict.keys())
|
235 |
colors = ["蓝色", "白色", "红色", "自定义底色"]
|
236 |
render = ["纯色", "上下渐变(白)", "中心渐变(白)"]
|
237 |
image_kb = ["不设置", "自定义"]
|
data_utils.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
|
3 |
+
|
4 |
+
def csv_to_size_list(csv_file: str) -> dict:
|
5 |
+
# 初始化一个空字典
|
6 |
+
size_list_dict = {}
|
7 |
+
|
8 |
+
# 打开CSV文件并读取数据
|
9 |
+
with open(csv_file, mode="r") as file:
|
10 |
+
reader = csv.reader(file)
|
11 |
+
# 跳过表头
|
12 |
+
next(reader)
|
13 |
+
# 读取数据并填充字典
|
14 |
+
for row in reader:
|
15 |
+
size_name, h, w = row
|
16 |
+
size_list_dict[size_name] = (int(h), int(w))
|
17 |
+
|
18 |
+
return size_list_dict
|
size_list_CN.csv
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Name,Height,Width
|
2 |
+
一寸,413,295
|
3 |
+
二寸,626,413
|
4 |
+
小一寸,378,260
|
5 |
+
小二寸,531,413
|
6 |
+
大一寸,567,390
|
7 |
+
大二寸,626,413
|
8 |
+
五寸,1499,1050
|
9 |
+
教师资格证,413,295
|
10 |
+
国家公务员考试,413,295
|
11 |
+
初级会计考试,413,295
|
12 |
+
英语四六级考试,192,144
|
13 |
+
计算机等级考试,567,390
|
14 |
+
研究生考试,709,531
|
15 |
+
社保卡,441,358
|
16 |
+
电子驾驶证,378,260
|