Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 == "
|
| 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
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
| 72 |
|
| 73 |
with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as app:
|
| 74 |
gr.Markdown("# ๐ญ Fashion AI Studio")
|
| 75 |
-
gr.Markdown("
|
| 76 |
|
| 77 |
-
with gr.
|
| 78 |
-
#
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
with gr.Row():
|
| 81 |
-
|
| 82 |
-
|
| 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 |
-
|
| 156 |
-
fn=
|
| 157 |
-
inputs=[
|
| 158 |
-
outputs=[
|
| 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(
|