Update app.py
Browse files
app.py
CHANGED
|
@@ -10,9 +10,10 @@ from PIL import PngImagePlugin
|
|
| 10 |
BASE_MODEL_ID = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 11 |
|
| 12 |
# LoRA réalisme global
|
| 13 |
-
LORA_PHOTO_REPO = "ostris/photorealistic-slider-sdxl-lora"
|
| 14 |
-
|
| 15 |
-
LORA_PHOTO_ADAPTER = "photo_realism"
|
|
|
|
| 16 |
|
| 17 |
# LoRA amélioration de visages
|
| 18 |
#LORA_FACE_REPO = "ostris/face-helper-sdxl-lora"
|
|
@@ -31,12 +32,19 @@ pipe = AutoPipelineForText2Image.from_pretrained(
|
|
| 31 |
pipe.to(DEVICE)
|
| 32 |
pipe.set_progress_bar_config(disable=True)
|
| 33 |
|
| 34 |
-
print("Chargement LoRA photorealistic...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
pipe.load_lora_weights(
|
| 36 |
-
|
| 37 |
-
|
|
|
|
| 38 |
)
|
| 39 |
|
|
|
|
| 40 |
print("Chargement LoRA face-helper...")
|
| 41 |
pipe.load_lora_weights(
|
| 42 |
LORA_FACE_REPO,
|
|
@@ -92,6 +100,12 @@ def generate(
|
|
| 92 |
adapters.append(LORA_FACE_ADAPTER)
|
| 93 |
weights.append(0.0)
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
pipe.set_adapters(adapters, adapter_weights=weights)
|
| 96 |
|
| 97 |
try:
|
|
@@ -214,6 +228,7 @@ with gr.Blocks(title="SDXL + LoRA (Diffusers)") as demo:
|
|
| 214 |
label="Force LoRA photorealistic",
|
| 215 |
)
|
| 216 |
|
|
|
|
| 217 |
face_enabled = gr.Checkbox(
|
| 218 |
label="Activer LoRA face-helper (visages)",
|
| 219 |
value=True,
|
|
@@ -231,6 +246,19 @@ with gr.Blocks(title="SDXL + LoRA (Diffusers)") as demo:
|
|
| 231 |
value="sdxl_lora_generation",
|
| 232 |
)
|
| 233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
run_btn = gr.Button("Générer", variant="primary")
|
| 235 |
|
| 236 |
with gr.Column():
|
|
@@ -260,6 +288,8 @@ with gr.Blocks(title="SDXL + LoRA (Diffusers)") as demo:
|
|
| 260 |
face_enabled,
|
| 261 |
face_weight,
|
| 262 |
script_name,
|
|
|
|
|
|
|
| 263 |
],
|
| 264 |
outputs=[out_img, out_script, out_file],
|
| 265 |
)
|
|
|
|
| 10 |
BASE_MODEL_ID = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 11 |
|
| 12 |
# LoRA réalisme global
|
| 13 |
+
#LORA_PHOTO_REPO = "ostris/photorealistic-slider-sdxl-lora"
|
| 14 |
+
LORA_PHOTO_REPO = "Muapi/hourglass-body-shape-sd1.5-sdxl-pony-flux-olaz"
|
| 15 |
+
#LORA_PHOTO_ADAPTER = "photo_realism"
|
| 16 |
+
LORA_PHOTO_ADAPTER = "hourglass_body"
|
| 17 |
|
| 18 |
# LoRA amélioration de visages
|
| 19 |
#LORA_FACE_REPO = "ostris/face-helper-sdxl-lora"
|
|
|
|
| 32 |
pipe.to(DEVICE)
|
| 33 |
pipe.set_progress_bar_config(disable=True)
|
| 34 |
|
| 35 |
+
#print("Chargement LoRA photorealistic...")
|
| 36 |
+
#pipe.load_lora_weights(
|
| 37 |
+
# LORA_PHOTO_REPO,
|
| 38 |
+
# adapter_name=LORA_PHOTO_ADAPTER,
|
| 39 |
+
#)
|
| 40 |
+
print("Chargement LoRA hourglass body...")
|
| 41 |
pipe.load_lora_weights(
|
| 42 |
+
LORA_HOURGLASS_FILE, # chemin local relatif
|
| 43 |
+
weight_name=LORA_HOURGLASS_FILE,
|
| 44 |
+
adapter_name=LORA_HOURGLASS_ADAPTER,
|
| 45 |
)
|
| 46 |
|
| 47 |
+
|
| 48 |
print("Chargement LoRA face-helper...")
|
| 49 |
pipe.load_lora_weights(
|
| 50 |
LORA_FACE_REPO,
|
|
|
|
| 100 |
adapters.append(LORA_FACE_ADAPTER)
|
| 101 |
weights.append(0.0)
|
| 102 |
|
| 103 |
+
# NOUVEAU : Hourglass body
|
| 104 |
+
hourglass_enabled = True # ou passe en param UI
|
| 105 |
+
hourglass_weight = 0.9 # recommandé par l'auteur [web:19]
|
| 106 |
+
adapters.append(LORA_HOURGLASS_ADAPTER)
|
| 107 |
+
weights.append(float(hourglass_weight) if hourglass_enabled else 0.0)
|
| 108 |
+
|
| 109 |
pipe.set_adapters(adapters, adapter_weights=weights)
|
| 110 |
|
| 111 |
try:
|
|
|
|
| 228 |
label="Force LoRA photorealistic",
|
| 229 |
)
|
| 230 |
|
| 231 |
+
|
| 232 |
face_enabled = gr.Checkbox(
|
| 233 |
label="Activer LoRA face-helper (visages)",
|
| 234 |
value=True,
|
|
|
|
| 246 |
value="sdxl_lora_generation",
|
| 247 |
)
|
| 248 |
|
| 249 |
+
hourglass_enabled = gr.Checkbox(
|
| 250 |
+
label="Activer LoRA hourglass body shape",
|
| 251 |
+
value=True,
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
hourglass_weight = gr.Slider(
|
| 255 |
+
minimum=0.0,
|
| 256 |
+
maximum=2.0,
|
| 257 |
+
value=0.9, # valeur recommandée [web:19]
|
| 258 |
+
step=0.05,
|
| 259 |
+
label="Force LoRA hourglass body",
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
run_btn = gr.Button("Générer", variant="primary")
|
| 263 |
|
| 264 |
with gr.Column():
|
|
|
|
| 288 |
face_enabled,
|
| 289 |
face_weight,
|
| 290 |
script_name,
|
| 291 |
+
hourglass_enabled,
|
| 292 |
+
hourglass_weight,
|
| 293 |
],
|
| 294 |
outputs=[out_img, out_script, out_file],
|
| 295 |
)
|