mralamdari commited on
Commit
d855c8d
·
verified ·
1 Parent(s): e85b698

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -0
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = ['کشی', 'چسب دار', 'بند دار', 'بدون بند', 'زیپ دار']
10
+ sex_list = ['بزرگسال', 'بزرگسال زنانه', 'بزرگسال مردانه', 'بچگانه', 'بچگانه دختر', 'بچگانه پسر']
11
+ sizes = [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
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
+ Flag = True
20
+ shoe_code,shoe_name,shoe_company,shoe_sizes,shoe_colors,shoe_shoelaces,shoe_sexes,shoe_types = shoes_data.iloc[i].values
21
+ shoes = [shoe_sizes.split('-'), shoe_sexes.split('-'), shoe_colors.split('-'), shoe_types.split('-'), shoe_shoelaces.split('-')]
22
+ for select_details, shoe_details in zip(selection, shoes):
23
+ if not select_details:
24
+ continue
25
+ for shoe_d in shoe_details:
26
+ if shoe_d not in select_details:
27
+ Flag = False
28
+ break
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
+ return shoes_arr
38
+
39
+ demo = gr.Interface(
40
+ sentence_builder,
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
+ "text",
49
+ # examples=[
50
+ # [42, "cat", ["Japan", "Pakistan"], "park", ["ate", "swam"], True],
51
+ # [4, "dog", ["Japan"], "zoo", ["ate", "swam"], False],
52
+ # [10, "bird", ["USA", "Pakistan"], "road", ["ran"], False],
53
+ # [8, "cat", ["Pakistan"], "zoo", ["ate"], True],
54
+ # ]
55
+ )
56
+
57
+ demo.launch()