Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
3 |
from clothGen import cloth_gen
|
4 |
from user_dress import user_cloths
|
5 |
import requests
|
@@ -10,13 +10,14 @@ 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 |
-
|
18 |
-
|
19 |
-
return gallery[evt.index][0]
|
20 |
|
21 |
|
22 |
def update_choices(dropout1, dropout2,):
|
@@ -71,7 +72,7 @@ with gr.Blocks(css="styles.css", theme=gr.themes.Base()) as demo:
|
|
71 |
image_output_1 = gr.Image(label="显示图像", value="image 209.png")
|
72 |
|
73 |
gallery_1 = gr.Gallery(
|
74 |
-
label="服装", elem_id="gallery",
|
75 |
value=[
|
76 |
# os.path.join(example_path, '上衣/_WEB_2016_09_26__2016092617451357e8ee2957aa1_TD.jpg'),
|
77 |
# os.path.join(example_path, '上衣/_WEB_2016_09_27__2016092717211057ea3a069c749_TD.jpg'),
|
@@ -108,7 +109,7 @@ with gr.Blocks(css="styles.css", theme=gr.themes.Base()) as demo:
|
|
108 |
with gr.Row():
|
109 |
submit_button_3 = gr.Button("服饰及搭配兼容性排序")
|
110 |
with gr.Row():
|
111 |
-
image_output_5 = gr.Image(label="显示图像", show_label=False, min_width=200, height=350)
|
112 |
intro = gr.Textbox(label="服饰介绍", lines=14, max_lines=14)
|
113 |
with gr.Row():
|
114 |
gallery_user = gr.Gallery(
|
@@ -119,13 +120,14 @@ with gr.Blocks(css="styles.css", theme=gr.themes.Base()) as demo:
|
|
119 |
object_fit="contain",
|
120 |
min_width=200,
|
121 |
height=350,
|
122 |
-
|
123 |
with gr.Row():
|
124 |
submit_button_4 = gr.Button("虚拟试穿")
|
125 |
with gr.Row():
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
129 |
with gr.Row():
|
130 |
gr.Markdown("""
|
131 |
女性体型备注:
|
@@ -143,28 +145,28 @@ with gr.Blocks(css="styles.css", theme=gr.themes.Base()) as demo:
|
|
143 |
5. **胖型身材**:腰围比胸围或肩宽**至少大10厘米**
|
144 |
""")
|
145 |
|
146 |
-
submit_button_1.click(fn=
|
147 |
inputs=[text_input1, text_input2, text_input3, text_input4, text_input5,
|
148 |
text_input6, text_input7, text_input8, text_input9, dropdown_input1,
|
149 |
dropdown_input2, dropdown_input3, text_input10, text_input11, text_input12,
|
150 |
feedback, user_pic],
|
151 |
-
outputs=text_output1)
|
152 |
submit_button_2.click(fn=cloth_gen,
|
153 |
-
inputs=
|
154 |
outputs=[gallery_1, image_output_5, intro])
|
155 |
|
156 |
-
gallery_1.select(get_select_index, gallery_1, image_output_5)
|
157 |
submit_button_3.click(fn=cal_compatibility,
|
158 |
inputs=[],
|
159 |
outputs=[gallery_4])
|
160 |
submit_button_4.click(fn=user_cloths,
|
161 |
inputs=[user_pic, image_output_5],
|
162 |
outputs=gallery_user)
|
163 |
-
submit_button_5.click(fn=
|
164 |
inputs=[text_input1, text_input2, text_input3, text_input4, text_input5,
|
165 |
text_input6, text_input7, text_input8, text_input9, dropdown_input1,
|
166 |
dropdown_input2, dropdown_input3, text_input10, text_input11, text_input12,
|
167 |
feedback, user_pic],
|
168 |
-
outputs=text_output1)
|
169 |
|
170 |
demo.launch(server_port=7860, share=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
from sugg_gene import suggest_gene
|
3 |
from clothGen import cloth_gen
|
4 |
from user_dress import user_cloths
|
5 |
import requests
|
|
|
10 |
|
11 |
|
12 |
gen_pic_num = 6
|
13 |
+
save_directory = "downloads"
|
14 |
|
15 |
|
16 |
def get_select_index(evt: gr.SelectData, gallery):
|
17 |
print(gallery[evt.index][0])
|
18 |
+
with open(os.path.join(save_directory, f"cloth_intro_{evt.index//2+1}.txt"), "r") as f:
|
19 |
+
introduction = f.read()
|
20 |
+
return gallery[evt.index][0], introduction
|
21 |
|
22 |
|
23 |
def update_choices(dropout1, dropout2,):
|
|
|
72 |
image_output_1 = gr.Image(label="显示图像", value="image 209.png")
|
73 |
|
74 |
gallery_1 = gr.Gallery(
|
75 |
+
label="服装", elem_id="gallery", interactive=False,
|
76 |
value=[
|
77 |
# os.path.join(example_path, '上衣/_WEB_2016_09_26__2016092617451357e8ee2957aa1_TD.jpg'),
|
78 |
# os.path.join(example_path, '上衣/_WEB_2016_09_27__2016092717211057ea3a069c749_TD.jpg'),
|
|
|
109 |
with gr.Row():
|
110 |
submit_button_3 = gr.Button("服饰及搭配兼容性排序")
|
111 |
with gr.Row():
|
112 |
+
image_output_5 = gr.Image(label="显示图像", show_label=False, min_width=200, height=350, interactive=False)
|
113 |
intro = gr.Textbox(label="服饰介绍", lines=14, max_lines=14)
|
114 |
with gr.Row():
|
115 |
gallery_user = gr.Gallery(
|
|
|
120 |
object_fit="contain",
|
121 |
min_width=200,
|
122 |
height=350,
|
123 |
+
)
|
124 |
with gr.Row():
|
125 |
submit_button_4 = gr.Button("虚拟试穿")
|
126 |
with gr.Row():
|
127 |
+
feedback = gr.Textbox(label="反馈", placeholder="可以从款式、颜色、图案、风格倾向、文化偏好角度进行反馈", lines=1,
|
128 |
+
max_lines=1, elem_id="feedback")
|
129 |
+
with gr.Row():
|
130 |
+
submit_button_5 = gr.Button("反馈")
|
131 |
with gr.Row():
|
132 |
gr.Markdown("""
|
133 |
女性体型备注:
|
|
|
145 |
5. **胖型身材**:腰围比胸围或肩宽**至少大10厘米**
|
146 |
""")
|
147 |
|
148 |
+
submit_button_1.click(fn=suggest_gene,
|
149 |
inputs=[text_input1, text_input2, text_input3, text_input4, text_input5,
|
150 |
text_input6, text_input7, text_input8, text_input9, dropdown_input1,
|
151 |
dropdown_input2, dropdown_input3, text_input10, text_input11, text_input12,
|
152 |
feedback, user_pic],
|
153 |
+
outputs=[text_output1])
|
154 |
submit_button_2.click(fn=cloth_gen,
|
155 |
+
inputs=dropdown_input1,
|
156 |
outputs=[gallery_1, image_output_5, intro])
|
157 |
|
158 |
+
gallery_1.select(fn=get_select_index, inputs=gallery_1, outputs=[image_output_5, intro])
|
159 |
submit_button_3.click(fn=cal_compatibility,
|
160 |
inputs=[],
|
161 |
outputs=[gallery_4])
|
162 |
submit_button_4.click(fn=user_cloths,
|
163 |
inputs=[user_pic, image_output_5],
|
164 |
outputs=gallery_user)
|
165 |
+
submit_button_5.click(fn=suggest_gene,
|
166 |
inputs=[text_input1, text_input2, text_input3, text_input4, text_input5,
|
167 |
text_input6, text_input7, text_input8, text_input9, dropdown_input1,
|
168 |
dropdown_input2, dropdown_input3, text_input10, text_input11, text_input12,
|
169 |
feedback, user_pic],
|
170 |
+
outputs=[text_output1])
|
171 |
|
172 |
demo.launch(server_port=7860, share=True)
|