aiqcamp commited on
Commit
1c71c6c
โ€ข
1 Parent(s): 43af73f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -84
app.py CHANGED
@@ -23,6 +23,19 @@ pipe.to("cuda")
23
 
24
  MAX_SEED = 2**32-1
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  @spaces.GPU()
27
  def generate_fashion(prompt, mode, cfg_scale, steps, randomize_seed, seed, width, height, lora_scale, progress=gr.Progress(track_tqdm=True)):
28
  # ํ•œ๊ธ€ ๊ฐ์ง€ ๋ฐ ๋ฒˆ์—ญ
@@ -36,7 +49,7 @@ def generate_fashion(prompt, mode, cfg_scale, steps, randomize_seed, seed, width
36
  actual_prompt = prompt
37
 
38
  # ๋ชจ๋“œ์— ๋”ฐ๋ฅธ LoRA ๋ฐ ํŠธ๋ฆฌ๊ฑฐ์›Œ๋“œ ์„ค์ •
39
- if mode == "Generate Model":
40
  pipe.load_lora_weights(model_lora_repo)
41
  trigger_word = "fashion photography, professional model"
42
  else:
@@ -66,96 +79,64 @@ def generate_fashion(prompt, mode, cfg_scale, steps, randomize_seed, seed, width
66
  progress(100, "Completed!")
67
  return image, seed
68
 
69
- def generate_image(prompt, structure_image, style_image, depth_strength, style_strength):
70
- # ์‹ค์ œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ ๋กœ์ง์„ ์—ฌ๊ธฐ์— ๊ตฌํ˜„
71
- return Image.new('RGB', (512, 512), 'white')
 
 
72
 
73
  with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as app:
74
  gr.Markdown("# ๐ŸŽญ Fashion AI Studio")
75
- gr.Markdown("Generate fashion images and try on virtual clothing using AI")
76
 
77
- with gr.Tabs():
78
- # Virtual Try-On ํƒญ
79
- with gr.TabItem("๐Ÿ‘” Virtual Try-On"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  with gr.Row():
81
- with gr.Column():
82
- prompt_input = gr.Textbox(
83
- label="Style Description",
84
- placeholder="Describe the desired style (e.g., 'person wearing elegant dress')"
85
- )
86
- with gr.Row():
87
- with gr.Group():
88
- structure_image = gr.Image(
89
- label="Your Photo (Full-body)",
90
- type="filepath"
91
- )
92
- gr.Markdown("*Upload a clear, well-lit full-body photo*")
93
- depth_strength = gr.Slider(
94
- minimum=0,
95
- maximum=50,
96
- value=15,
97
- label="Fitting Strength"
98
- )
99
- with gr.Group():
100
- style_image = gr.Image(
101
- label="Clothing Item",
102
- type="filepath"
103
- )
104
- gr.Markdown("*Upload the clothing item you want to try on*")
105
- style_strength = gr.Slider(
106
- minimum=0,
107
- maximum=1,
108
- value=0.5,
109
- label="Style Transfer Strength"
110
- )
111
- tryon_btn = gr.Button("Generate Try-On")
112
-
113
- with gr.Column():
114
- output_image = gr.Image(label="Generated Result")
115
-
116
- # Fashion Generation ํƒญ
117
- with gr.TabItem("๐Ÿ‘— Fashion Generation"):
118
- with gr.Column():
119
- # ๋ชจ๋“œ ์„ ํƒ
120
- with gr.Group():
121
- mode = gr.Radio(
122
- choices=["Generate Model", "Generate Clothes"],
123
- label="Generation Mode",
124
- value="Generate Model"
125
- )
126
-
127
- # ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ
128
- prompt = gr.TextArea(
129
- label="โœ๏ธ Fashion Description (ํ•œ๊ธ€ ๋˜๋Š” ์˜์–ด)",
130
- placeholder="ํŒจ์…˜ ๋ชจ๋ธ์ด๋‚˜ ์˜๋ฅ˜๋ฅผ ์„ค๋ช…ํ•˜์„ธ์š”...",
131
- lines=5
132
- )
133
-
134
- # ๊ฒฐ๊ณผ ์ด๋ฏธ์ง€
135
- result = gr.Image(label="Generated Fashion")
136
-
137
- generate_button = gr.Button("๐Ÿš€ Generate Fashion")
138
-
139
- # ๊ณ ๊ธ‰ ์„ค์ • ์•„์ฝ”๋””์–ธ
140
- with gr.Accordion("๐ŸŽจ Advanced Options", open=False):
141
- with gr.Row():
142
- cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7.0)
143
- steps = gr.Slider(label="Steps", minimum=1, maximum=100, value=30)
144
- lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=1, value=0.85)
145
-
146
- with gr.Row():
147
- width = gr.Slider(label="Width", minimum=256, maximum=1536, value=512)
148
- height = gr.Slider(label="Height", minimum=256, maximum=1536, value=768)
149
-
150
- with gr.Row():
151
- randomize_seed = gr.Checkbox(True, label="Randomize seed")
152
- seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, value=42)
153
 
154
  # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ
155
- tryon_btn.click(
156
- fn=generate_image,
157
- inputs=[prompt_input, structure_image, style_image, depth_strength, style_strength],
158
- outputs=[output_image]
159
  )
160
 
161
  generate_button.click(
 
23
 
24
  MAX_SEED = 2**32-1
25
 
26
+ # ์˜ˆ์‹œ ํ”„๋กฌํ”„ํŠธ ์ •์˜
27
+ model_examples = [
28
+ "professional fashion model wearing elegant black dress in studio lighting",
29
+ "fashion model in casual street wear, urban background",
30
+ "high fashion model in avant-garde outfit on runway"
31
+ ]
32
+
33
+ clothes_examples = [
34
+ "luxurious red evening gown with detailed embroidery",
35
+ "casual denim jacket with vintage wash",
36
+ "modern minimalist white blazer with clean lines"
37
+ ]
38
+
39
  @spaces.GPU()
40
  def generate_fashion(prompt, mode, cfg_scale, steps, randomize_seed, seed, width, height, lora_scale, progress=gr.Progress(track_tqdm=True)):
41
  # ํ•œ๊ธ€ ๊ฐ์ง€ ๋ฐ ๋ฒˆ์—ญ
 
49
  actual_prompt = prompt
50
 
51
  # ๋ชจ๋“œ์— ๋”ฐ๋ฅธ LoRA ๋ฐ ํŠธ๋ฆฌ๊ฑฐ์›Œ๋“œ ์„ค์ •
52
+ if mode == "ํŒจ์…˜ ๋ชจ๋ธ ์ƒ์„ฑ":
53
  pipe.load_lora_weights(model_lora_repo)
54
  trigger_word = "fashion photography, professional model"
55
  else:
 
79
  progress(100, "Completed!")
80
  return image, seed
81
 
82
+ def update_examples(mode):
83
+ if mode == "ํŒจ์…˜ ๋ชจ๋ธ ์ƒ์„ฑ":
84
+ return gr.Examples(examples=model_examples)
85
+ else:
86
+ return gr.Examples(examples=clothes_examples)
87
 
88
  with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as app:
89
  gr.Markdown("# ๐ŸŽญ Fashion AI Studio")
90
+ gr.Markdown("AI๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŒจ์…˜ ๋ชจ๋ธ๊ณผ ์˜๋ฅ˜๋ฅผ ์ƒ์„ฑํ•ด๋ณด์„ธ์š”")
91
 
92
+ with gr.Column():
93
+ # ๋ชจ๋“œ ์„ ํƒ
94
+ mode = gr.Radio(
95
+ choices=["ํŒจ์…˜ ๋ชจ๋ธ ์ƒ์„ฑ", "ํŒจ์…˜ ์˜๋ฅ˜ ์ƒ์„ฑ"],
96
+ label="์ƒ์„ฑ ๋ชจ๋“œ",
97
+ value="ํŒจ์…˜ ๋ชจ๋ธ ์ƒ์„ฑ"
98
+ )
99
+
100
+ # ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ
101
+ prompt = gr.TextArea(
102
+ label="โœ๏ธ ํŒจ์…˜ ์„ค๋ช… (ํ•œ๊ธ€ ๋˜๋Š” ์˜์–ด)",
103
+ placeholder="ํŒจ์…˜ ๋ชจ๋ธ์ด๋‚˜ ์˜๋ฅ˜๋ฅผ ์„ค๋ช…ํ•˜์„ธ์š”...",
104
+ lines=3
105
+ )
106
+
107
+ # ์˜ˆ์‹œ ์„น์…˜
108
+ with gr.Column() as example_container:
109
+ examples = gr.Examples(
110
+ examples=model_examples,
111
+ inputs=prompt,
112
+ label="์˜ˆ์‹œ ํ”„๋กฌํ”„ํŠธ"
113
+ )
114
+
115
+ # ๊ฒฐ๊ณผ ์ด๋ฏธ์ง€
116
+ result = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€")
117
+
118
+ generate_button = gr.Button("๐Ÿš€ ์ด๋ฏธ์ง€ ์ƒ์„ฑ")
119
+
120
+ # ๊ณ ๊ธ‰ ์„ค์ •
121
+ with gr.Accordion("๐ŸŽจ ๊ณ ๊ธ‰ ์„ค์ •", open=False):
122
+ with gr.Row():
123
+ cfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7.0)
124
+ steps = gr.Slider(label="Steps", minimum=1, maximum=100, value=30)
125
+ lora_scale = gr.Slider(label="LoRA Scale", minimum=0, maximum=1, value=0.85)
126
+
127
+ with gr.Row():
128
+ width = gr.Slider(label="Width", minimum=256, maximum=1536, value=512)
129
+ height = gr.Slider(label="Height", minimum=256, maximum=1536, value=768)
130
+
131
  with gr.Row():
132
+ randomize_seed = gr.Checkbox(True, label="์‹œ๋“œ ๋žœ๋คํ™”")
133
+ seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, value=42)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
  # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ
136
+ mode.change(
137
+ fn=update_examples,
138
+ inputs=[mode],
139
+ outputs=[examples]
140
  )
141
 
142
  generate_button.click(