qbhf2 commited on
Commit
9185355
·
verified ·
1 Parent(s): f365a20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -5
app.py CHANGED
@@ -2,6 +2,35 @@ import gradio as gr
2
  from custom_utils.setup_env import run_setup_script
3
 
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  with gr.Blocks(title="3D Garment Generator", theme=gr.themes.Default(text_size="sm")) as demo:
6
  # Состояния для хранения выбранных значений
7
  front_collar = gr.State()
@@ -24,19 +53,35 @@ with gr.Blocks(title="3D Garment Generator", theme=gr.themes.Default(text_size="
24
 
25
  with gr.Row():
26
  with gr.Column(scale=1):
27
- with gr.Accordion("3. Параметры генерации", open=False):
 
 
 
 
 
 
 
 
28
  front_dropdown = gr.Dropdown(
 
29
  label="Front Collar",
30
- choices=["CircleNeckHalf", "CurvyNeckHalf", "VNeckHalf", "SquareNeckHalf",
31
- "TrapezoidNeckHalf", "CircleArcNeckHalf", "Bezier2NeckHalf"],
32
  interactive=True
33
  )
 
34
  back_dropdown = gr.Dropdown(
 
35
  label="Back Collar",
36
- choices=["CircleNeckHalf", "CurvyNeckHalf", "VNeckHalf", "SquareNeckHalf",
37
- "TrapezoidNeckHalf", "CircleArcNeckHalf", "Bezier2NeckHalf"],
38
  interactive=True
39
  )
 
 
 
 
 
 
 
40
 
41
  with gr.Accordion("4. Render engine", open=False):
42
  render_radio = gr.Radio(
 
2
  from custom_utils.setup_env import run_setup_script
3
 
4
 
5
+ def update_submenu(clothing_type):
6
+ """Функция для динамического обновления подменю в зависимости от типа одежды."""
7
+ if clothing_type == "Top":
8
+ return gr.Dropdown.update(
9
+ visible=True,
10
+ label="Front Collar",
11
+ choices=["CircleNeckHalf", "CurvyNeckHalf", "VNeckHalf", "SquareNeckHalf",
12
+ "TrapezoidNeckHalf", "CircleArcNeckHalf", "Bezier2NeckHalf"]
13
+ ), gr.Dropdown.update(
14
+ visible=True,
15
+ label="Back Collar",
16
+ choices=["CircleNeckHalf", "CurvyNeckHalf", "VNeckHalf", "SquareNeckHalf",
17
+ "TrapezoidNeckHalf", "CircleArcNeckHalf", "Bezier2NeckHalf"]
18
+ )
19
+ elif clothing_type == "Down":
20
+ return gr.Dropdown.update(
21
+ visible=True,
22
+ label="Waist Style",
23
+ choices=["High Waist", "Low Waist", "Medium Waist"]
24
+ ), None # Нет второго параметра для Down
25
+ elif clothing_type == "Full body":
26
+ return gr.Dropdown.update(
27
+ visible=True,
28
+ label="Overall Style",
29
+ choices=["Slim Fit", "Loose Fit", "Regular Fit"]
30
+ ), None # Нет второго параметра для Full body
31
+ else:
32
+ return None, None
33
+
34
  with gr.Blocks(title="3D Garment Generator", theme=gr.themes.Default(text_size="sm")) as demo:
35
  # Состояния для хранения выбранных значений
36
  front_collar = gr.State()
 
53
 
54
  with gr.Row():
55
  with gr.Column(scale=1):
56
+ with gr.Accordion("3. Параметры генерации", open=True):
57
+ # Выбор типа одежды
58
+ clothing_type_dropdown = gr.Dropdown(
59
+ label="Тип одежды",
60
+ choices=["Top", "Down", "Full body"],
61
+ interactive=True
62
+ )
63
+
64
+ # Подменю (изначально скрытое)
65
  front_dropdown = gr.Dropdown(
66
+ visible=False,
67
  label="Front Collar",
68
+ choices=[],
 
69
  interactive=True
70
  )
71
+
72
  back_dropdown = gr.Dropdown(
73
+ visible=False,
74
  label="Back Collar",
75
+ choices=[],
 
76
  interactive=True
77
  )
78
+
79
+ # Обновление подменю при изменении типа одежды
80
+ clothing_type_dropdown.change(
81
+ fn=update_submenu,
82
+ inputs=clothing_type_dropdown,
83
+ outputs=[front_dropdown, back_dropdown]
84
+ )
85
 
86
  with gr.Accordion("4. Render engine", open=False):
87
  render_radio = gr.Radio(