Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import numpy as np
|
|
| 6 |
from PIL import Image, ImageFilter, ImageDraw
|
| 7 |
|
| 8 |
import torch
|
| 9 |
-
from diffusers import StableDiffusionInpaintPipeline
|
| 10 |
|
| 11 |
# ------------------------------
|
| 12 |
# Config & model
|
|
@@ -24,6 +24,8 @@ pipe = StableDiffusionInpaintPipeline.from_pretrained(
|
|
| 24 |
torch_dtype=DTYPE,
|
| 25 |
safety_checker=None, # для локального теста
|
| 26 |
).to(DEVICE)
|
|
|
|
|
|
|
| 27 |
pipe.enable_attention_slicing()
|
| 28 |
if DEVICE == "cuda":
|
| 29 |
try:
|
|
@@ -152,7 +154,12 @@ def outpaint_generate(
|
|
| 152 |
# Gradio UI
|
| 153 |
# ------------------------------
|
| 154 |
DEFAULT_PROMPT = "extend the image naturally, seamless realistic background, consistent lighting, matching style"
|
| 155 |
-
DEFAULT_NEG =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
with gr.Blocks(css="""
|
| 158 |
#mini {font-size: 0.9em; opacity: 0.9}
|
|
@@ -169,7 +176,7 @@ with gr.Blocks(css="""
|
|
| 169 |
nprmpt = gr.Textbox(value=DEFAULT_NEG, label="Negative prompt")
|
| 170 |
with gr.Row():
|
| 171 |
steps = gr.Slider(10, 60, value=30, step=1, label="Steps")
|
| 172 |
-
cfg = gr.Slider(1.0,
|
| 173 |
seed = gr.Number(value=-1, precision=0, label="Seed (-1 = random)")
|
| 174 |
go_btn = gr.Button("Generate", variant="primary")
|
| 175 |
|
|
|
|
| 6 |
from PIL import Image, ImageFilter, ImageDraw
|
| 7 |
|
| 8 |
import torch
|
| 9 |
+
from diffusers import StableDiffusionInpaintPipeline, DPMSolverMultistepScheduler
|
| 10 |
|
| 11 |
# ------------------------------
|
| 12 |
# Config & model
|
|
|
|
| 24 |
torch_dtype=DTYPE,
|
| 25 |
safety_checker=None, # для локального теста
|
| 26 |
).to(DEVICE)
|
| 27 |
+
# Более «послушный» шагатель, лучше держит NEG и фон
|
| 28 |
+
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 29 |
pipe.enable_attention_slicing()
|
| 30 |
if DEVICE == "cuda":
|
| 31 |
try:
|
|
|
|
| 154 |
# Gradio UI
|
| 155 |
# ------------------------------
|
| 156 |
DEFAULT_PROMPT = "extend the image naturally, seamless realistic background, consistent lighting, matching style"
|
| 157 |
+
DEFAULT_NEG = (
|
| 158 |
+
"text, letters, words, caption, typography, logo, watermark, "
|
| 159 |
+
"numbers, digits, signboard, poster text, "
|
| 160 |
+
"lowres, blurry, artifacts, deformed, distorted, oversaturated, "
|
| 161 |
+
"frame, border, mosaic, collage, extra limbs"
|
| 162 |
+
)
|
| 163 |
|
| 164 |
with gr.Blocks(css="""
|
| 165 |
#mini {font-size: 0.9em; opacity: 0.9}
|
|
|
|
| 176 |
nprmpt = gr.Textbox(value=DEFAULT_NEG, label="Negative prompt")
|
| 177 |
with gr.Row():
|
| 178 |
steps = gr.Slider(10, 60, value=30, step=1, label="Steps")
|
| 179 |
+
cfg = gr.Slider(1.0, 9.0, value=6.5, step=0.5, label="CFG (guidance)")
|
| 180 |
seed = gr.Number(value=-1, precision=0, label="Seed (-1 = random)")
|
| 181 |
go_btn = gr.Button("Generate", variant="primary")
|
| 182 |
|