Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
def sentence_builder(sizes, types, colors, shoelaces, genders):
|
5 |
-
return f"{sizes}+ {types}+ {colors}+ {shoelaces}+ {genders}"
|
6 |
-
|
7 |
type_list = ['اسپرت', 'راحتی', 'پوتون', 'طبی', 'گوندارا', 'کالج', 'مجلسی', 'دمپایی', 'پاشنه دار', 'تابستانه', 'جورابی']
|
8 |
color_list = ['مشکی', 'سفید', 'قهوه ای', 'کرمی', 'خاکستری', 'طوسی', 'سبز', 'آبی', 'رنگارنگ']
|
9 |
shoelace_list = ['کشی', 'چسب دار', 'بند دار', 'بدون بند', 'زیپ دار']
|
@@ -12,40 +8,41 @@ sizes = [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
|
|
12 |
|
13 |
|
14 |
|
15 |
-
|
16 |
-
shoes_arr = []
|
17 |
-
selection = [list(map(int, selected_size)), selected_sex, selected_color, selected_type, selected_shoelace]
|
18 |
-
for i in range(len(shoes_data['code'].values)):
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
if not Flag:
|
31 |
-
break
|
32 |
-
if Flag:
|
33 |
-
shoes_arr.append({'name': shoe_name, 'code': str(shoe_code), 'sizes': shoe_sizes, 'image_url': os.path.join(root,IMAGE_DIR,str(shoe_code)+'.jpg')})
|
34 |
-
else:
|
35 |
-
shoes.append({'name': '', 'code': '', 'sizes': [], 'image_url': './static/Images/Empty.jpg'})
|
36 |
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
demo = gr.Interface(
|
40 |
-
|
41 |
-
[
|
42 |
gr.Dropdown(sizes, value=[42, 44], multiselect=True, label="sizes", info="Lor vel nisl."),
|
43 |
gr.CheckboxGroup(type_list, label="types", info="Where are they from?"),
|
44 |
gr.CheckboxGroup(color_list, label="colors", info="Where are they from?"),
|
45 |
gr.CheckboxGroup(shoelace_list, label="shoelaces", info="Where are they from?"),
|
46 |
gr.CheckboxGroup(sex_list, label="genders", info="Where are they from?"),
|
47 |
],
|
48 |
-
"
|
49 |
# examples=[
|
50 |
# [42, "cat", ["Japan", "Pakistan"], "park", ["ate", "swam"], True],
|
51 |
# [4, "dog", ["Japan"], "zoo", ["ate", "swam"], False],
|
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
3 |
type_list = ['اسپرت', 'راحتی', 'پوتون', 'طبی', 'گوندارا', 'کالج', 'مجلسی', 'دمپایی', 'پاشنه دار', 'تابستانه', 'جورابی']
|
4 |
color_list = ['مشکی', 'سفید', 'قهوه ای', 'کرمی', 'خاکستری', 'طوسی', 'سبز', 'آبی', 'رنگارنگ']
|
5 |
shoelace_list = ['کشی', 'چسب دار', 'بند دار', 'بدون بند', 'زیپ دار']
|
|
|
8 |
|
9 |
|
10 |
|
11 |
+
def show_shoes(sizes, types, colors, shoelaces, genders):
|
12 |
+
shoes_arr = []
|
13 |
+
selection = [list(map(int, selected_size)), selected_sex, selected_color, selected_type, selected_shoelace]
|
14 |
+
for i in range(len(shoes_data['code'].values)):
|
15 |
+
Flag = True
|
16 |
+
shoe_code,shoe_name,shoe_company,shoe_sizes,shoe_colors,shoe_shoelaces,shoe_sexes,shoe_types = shoes_data.iloc[i].values
|
17 |
+
shoes = [shoe_sizes.split('-'), shoe_sexes.split('-'), shoe_colors.split('-'), shoe_types.split('-'), shoe_shoelaces.split('-')]
|
18 |
+
for select_details, shoe_details in zip(selection, shoes):
|
19 |
+
if not select_details:
|
20 |
+
continue
|
21 |
+
for shoe_d in shoe_details:
|
22 |
+
if shoe_d not in select_details:
|
23 |
+
Flag = False
|
24 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
if not Flag:
|
27 |
+
break
|
28 |
+
if Flag:
|
29 |
+
# shoes_arr.append({'name': shoe_name, 'code': str(shoe_code), 'sizes': shoe_sizes, 'image_url': os.path.join(root,IMAGE_DIR,str(shoe_code)+'.jpg')})
|
30 |
+
shoes_arr.append(os.path.join(root,IMAGE_DIR,str(shoe_code)+'.jpg')
|
31 |
+
else:
|
32 |
+
shoes.append({'name': '', 'code': '', 'sizes': [], 'image_url': './static/Images/Empty.jpg'})
|
33 |
+
|
34 |
+
return shoes_arr
|
35 |
|
36 |
demo = gr.Interface(
|
37 |
+
fn=show_shoes,
|
38 |
+
inputs=[
|
39 |
gr.Dropdown(sizes, value=[42, 44], multiselect=True, label="sizes", info="Lor vel nisl."),
|
40 |
gr.CheckboxGroup(type_list, label="types", info="Where are they from?"),
|
41 |
gr.CheckboxGroup(color_list, label="colors", info="Where are they from?"),
|
42 |
gr.CheckboxGroup(shoelace_list, label="shoelaces", info="Where are they from?"),
|
43 |
gr.CheckboxGroup(sex_list, label="genders", info="Where are they from?"),
|
44 |
],
|
45 |
+
outputs=gr.Gallery(label="Generated Images", columns=[2]),
|
46 |
# examples=[
|
47 |
# [42, "cat", ["Japan", "Pakistan"], "park", ["ate", "swam"], True],
|
48 |
# [4, "dog", ["Japan"], "zoo", ["ate", "swam"], False],
|