SIUBIU commited on
Commit
04102c2
·
verified ·
1 Parent(s): e2387e1

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -159
app.py DELETED
@@ -1,159 +0,0 @@
1
- import gradio as gr
2
- from suggestion import generate_outfit_advice
3
- from clothGen import cloth_gen
4
- from user_dress import user_dress
5
- import requests
6
- import os
7
- from io import BytesIO
8
- from PIL import Image
9
- from cal_compatibility import cal_compatibility
10
-
11
-
12
- gen_pic_num = 6
13
-
14
-
15
- def get_select_index(evt: gr.SelectData, gallery):
16
- print(gallery[evt.index][0])
17
- # response = requests.get(gallery[evt.index][0])
18
- # img = Image.open(BytesIO(response.content))
19
- return gallery[evt.index][0]
20
-
21
-
22
-
23
-
24
-
25
- with gr.Blocks(css="styles.css", theme=gr.themes.Base()) as demo:
26
- with gr.Row():
27
- # 左侧模块
28
- with gr.Column(scale=1):
29
- with gr.Row():
30
- gr.Markdown(""
31
- "# 用户信息"
32
- "")
33
- with gr.Row():
34
- text_input1 = gr.Textbox(label="用户姓名", min_width=100)
35
- text_input2 = gr.Textbox(label="身高", min_width=100)
36
- text_input3 = gr.Textbox(label="体重", min_width=100)
37
- text_input4 = gr.Textbox(label="腰围", min_width=100)
38
- text_input5 = gr.Textbox(label="胸围", min_width=100)
39
- text_input6 = gr.Textbox(label="臀围", min_width=100)
40
- text_input7 = gr.Textbox(label="肩宽", min_width=100)
41
- text_input8 = gr.Textbox(label="腿长", min_width=100)
42
- text_input9 = gr.Textbox(label="臂长", min_width=100)
43
- dropdown_options1 = ["男", "女"]
44
- dropdown_input1 = gr.Dropdown(choices=dropdown_options1, label="性别", min_width=100)
45
- dropdown_options2 = ["胖", "瘦"]
46
- dropdown_input2 = gr.Dropdown(choices=dropdown_options2, label="体型分类", min_width=100)
47
- dropdown_options3 = ["黑", "黄", "白"]
48
- dropdown_input3 = gr.Dropdown(choices=dropdown_options3, label="肤色", min_width=100)
49
- text_input10 = gr.Textbox(label="穿衣风格偏好", min_width=1000)
50
- text_input11 = gr.Textbox(label="生话方式和场景需求", min_width=1000)
51
- text_input12 = gr.Textbox(label="其他特殊需求", min_width=1000)
52
- with gr.Row():
53
- user_pic = gr.Image(label="用户照片", value="model.jpg", height=550, width=300)
54
-
55
- # 右侧模块
56
- with gr.Column(scale=2):
57
- with gr.Row():
58
- gr.Markdown(""
59
- "# 穿搭建议"
60
- "")
61
- with gr.Row():
62
- text_output1 = gr.Textbox(label="穿搭建议", lines=12, max_lines=12, interactive=False, show_label=False,
63
- min_width=1000)
64
- submit_button_1 = gr.Button("AI智能分析,生成穿搭建议", min_width=1000)
65
- # 这里调用模型输出穿搭建议
66
- submit_button_1.click(fn=generate_outfit_advice,
67
-
68
- inputs=[text_input1, text_input2, text_input3, text_input4, text_input5,
69
- text_input6, text_input7, text_input8, text_input9, dropdown_input1,
70
- dropdown_input2, dropdown_input3, text_input10, text_input11, text_input12,
71
- user_pic],
72
- outputs=text_output1)
73
- image_output_1 = gr.Image(label="显示图像", value="image 209.png")
74
-
75
- gallery_1 = gr.Gallery(
76
- label="上装", elem_id="gallery",
77
- value=[
78
- # os.path.join(example_path, '上衣/_WEB_2016_09_26__2016092617451357e8ee2957aa1_TD.jpg'),
79
- # os.path.join(example_path, '上衣/_WEB_2016_09_27__2016092717211057ea3a069c749_TD.jpg'),
80
- # os.path.join(example_path, '上衣/_WEB_2016_09_27__2016092717391657ea3e446ce3f_TD.jpg'),
81
- # os.path.join(example_path, '上衣/_WEB_2016_09_27__2016092717573057ea428a305bc_TD.jpg'),
82
- # os.path.join(example_path, '上衣/_WEB_2016_09_28__2016092810150157eb27a56a631_TD.jpg'),
83
- # os.path.join(example_path, '上衣/_WEB_2016_09_28__2016092810464557eb2f15e1df3_TD.jpg'),
84
- ],
85
- columns=[4], rows=[2], object_fit="contain", height=250, min_width=450)
86
- # selected = gr.Number(show_label=False, visible=False)
87
-
88
-
89
- # gallery_2 = gr.Gallery(
90
- # label="下装", elem_id="gallery",
91
- # value=[
92
- # os.path.join(example_path, '裙/_WEB_2017_01_16__20170116144757587c6c9d6110d_TD.jpg'),
93
- # os.path.join(example_path, '裙/_WEB_2017_01_16__20170116150051587c6fa38aa08_TD.jpg'),
94
- # os.path.join(example_path, '裙/_WEB_2017_01_16__20170116151007587c71cf63864_TD.jpg'),
95
- # os.path.join(example_path, '裙/_WEB_2017_01_16__20170116151641587c7359ab8f3_TD.jpg'),
96
- # os.path.join(example_path, '裙/_WEB_2017_01_16__20170116152244587c74c439389_TD.jpg'),
97
- # os.path.join(example_path, '裙/_WEB_2017_01_17__20170117120901587d98dd09fd5_TD.jpg'),
98
- # ],
99
- # columns=[6], rows=[1], object_fit="contain", height=145, min_width=450)
100
- gallery_3 = gr.Gallery(
101
- label="配饰", elem_id="gallery",
102
- value=[
103
- 'downloads/access_1.jpg',
104
- 'downloads/access_2.jpg',
105
- 'downloads/access_3.jpg',
106
- 'downloads/access_4.jpg',
107
- 'downloads/access_5.jpg',
108
- 'downloads/access_6.jpg',
109
- ],
110
- columns=[4], rows=[2], object_fit="contain", height=250, min_width=450)
111
- submit_button_2 = gr.Button("AI智能分析,生成民族服饰")
112
-
113
- with gr.Column(scale=2):
114
- with gr.Row():
115
- gr.Markdown(""
116
- "# 搭配生成"
117
- "")
118
- with gr.Row():
119
- gallery_4 = gr.Gallery(
120
- label="套装", elem_id="gallery",
121
- value=[
122
-
123
- ],
124
- columns=[3], rows=[1], object_fit="contain", height=200, min_width=450)
125
- with gr.Row():
126
- submit_button_3 = gr.Button("服饰及搭配兼容性排序")
127
- with gr.Row():
128
- image_output_5 = gr.Image(label="显示图像", show_label=False, min_width=300, height=350)
129
- with gr.Row():
130
- submit_button_4 = gr.Button("虚拟试穿")
131
- with gr.Row():
132
- with gr.Column(scale=1):
133
- image_output_6 = gr.Image(label="显示图像", show_label=False, min_width=200, height=350)
134
- with gr.Column(scale=1):
135
- feedback = gr.Textbox(label="反馈", value="可以从款式、颜色、图案、风格倾向、文化偏好角度进行反馈", lines=1,
136
- max_lines=1, elem_id="feedback")
137
- submit_button_5 = gr.Button("反馈")
138
- # com_output = gr.Textbox(label="适配度")
139
-
140
- submit_button_2.click(fn=cloth_gen,
141
- inputs=[text_output1, dropdown_input1],
142
- outputs=gallery_1)
143
-
144
- gallery_1.select(get_select_index, gallery_1, image_output_5)
145
- submit_button_3.click(fn=cal_compatibility,
146
- inputs=[],
147
- outputs=[gallery_4])
148
- # user_pic_url = user_pic.value['url']
149
- submit_button_4.click(fn=user_dress,
150
- inputs=[user_pic, image_output_5],
151
- outputs=image_output_6)
152
- submit_button_5.click(fn=generate_outfit_advice,
153
- inputs=[text_input1, text_input2, text_input3, text_input4, text_input5,
154
- text_input6, text_input7, text_input8, text_input9, dropdown_input1,
155
- dropdown_input2, dropdown_input3, text_input10, text_input11, feedback,
156
- user_pic],
157
- outputs=text_output1)
158
-
159
- demo.launch(server_port=7860, share=True)