Spaces:
Running on Zero
Running on Zero
Remove dark mode toggles and raise quality defaults
Browse files- __pycache__/app.cpython-312.pyc +0 -0
- app.py +4 -89
__pycache__/app.cpython-312.pyc
ADDED
|
Binary file (6.44 kB). View file
|
|
|
app.py
CHANGED
|
@@ -13,8 +13,8 @@ from diffusers import StableDiffusionPipeline
|
|
| 13 |
|
| 14 |
|
| 15 |
MODEL_ID = os.getenv("MODEL_ID", "stabilityai/sd-turbo")
|
| 16 |
-
MAX_STEPS = int(os.getenv("MAX_STEPS", "
|
| 17 |
-
GPU_DURATION = max(10, min(int(os.getenv("GPU_DURATION", "
|
| 18 |
BUILD_TAG = os.getenv("SPACE_BUILD_TAG", datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC"))
|
| 19 |
|
| 20 |
_pipe: Optional[StableDiffusionPipeline] = None
|
|
@@ -325,15 +325,13 @@ with gr.Blocks(title="PixelForge ZeroGPU") as demo:
|
|
| 325 |
with gr.Column(scale=1):
|
| 326 |
prompt = gr.Textbox(label="Prompt", placeholder="z. B. cinematic cyberpunk city at night", lines=3)
|
| 327 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="blurry, low quality", lines=2)
|
| 328 |
-
steps = gr.Slider(1, MAX_STEPS, value=min(
|
| 329 |
-
guidance = gr.Slider(0.0, 8.0, value=
|
| 330 |
width = gr.Slider(256, 1024, value=768, step=64, label="Bildbreite")
|
| 331 |
height = gr.Slider(256, 1024, value=768, step=64, label="Bildhöhe")
|
| 332 |
seed = gr.Textbox(label="Seed", value="42")
|
| 333 |
adult_enabled = gr.Checkbox(label="Adult-Generierung erlauben (18+)", value=False)
|
| 334 |
realism_boost = gr.Checkbox(label="Realismus Boost", value=True)
|
| 335 |
-
full_dark_mode = gr.Checkbox(label="Dark Mode (gesamte Seite)", value=False)
|
| 336 |
-
dark_mode = gr.Checkbox(label="Dark Mode für Ergebnisbild", value=True)
|
| 337 |
style_select = gr.Dropdown(
|
| 338 |
label="Random Style",
|
| 339 |
choices=["Mix", "Cinematic", "Photo", "Anime", "Fantasy", "Studio"],
|
|
@@ -372,89 +370,6 @@ with gr.Blocks(title="PixelForge ZeroGPU") as demo:
|
|
| 372 |
api_name=False,
|
| 373 |
)
|
| 374 |
|
| 375 |
-
dark_mode.change(
|
| 376 |
-
fn=None,
|
| 377 |
-
inputs=[dark_mode],
|
| 378 |
-
outputs=None,
|
| 379 |
-
queue=False,
|
| 380 |
-
api_name=False,
|
| 381 |
-
js="""
|
| 382 |
-
(enabled) => {
|
| 383 |
-
const imageContainer = document.getElementById('result-image');
|
| 384 |
-
if (!imageContainer) return;
|
| 385 |
-
|
| 386 |
-
imageContainer.style.background = enabled ? '#0f1115' : '';
|
| 387 |
-
imageContainer.style.borderColor = enabled ? '#2a2f3a' : '';
|
| 388 |
-
|
| 389 |
-
const image = imageContainer.querySelector('img');
|
| 390 |
-
if (image) {
|
| 391 |
-
image.style.filter = enabled ? 'brightness(0.82)' : 'none';
|
| 392 |
-
}
|
| 393 |
-
}
|
| 394 |
-
""",
|
| 395 |
-
)
|
| 396 |
-
|
| 397 |
-
full_dark_mode.change(
|
| 398 |
-
fn=None,
|
| 399 |
-
inputs=[full_dark_mode],
|
| 400 |
-
outputs=None,
|
| 401 |
-
queue=False,
|
| 402 |
-
api_name=False,
|
| 403 |
-
js="""
|
| 404 |
-
(enabled) => {
|
| 405 |
-
const styleId = 'pf-global-dark-style';
|
| 406 |
-
let styleEl = document.getElementById(styleId);
|
| 407 |
-
|
| 408 |
-
if (!styleEl) {
|
| 409 |
-
styleEl = document.createElement('style');
|
| 410 |
-
styleEl.id = styleId;
|
| 411 |
-
styleEl.textContent = `
|
| 412 |
-
html.pf-dark, body.pf-dark {
|
| 413 |
-
background: #0b0d12 !important;
|
| 414 |
-
color: #e5e7eb !important;
|
| 415 |
-
}
|
| 416 |
-
body.pf-dark .gradio-container {
|
| 417 |
-
background: #0b0d12 !important;
|
| 418 |
-
color: #e5e7eb !important;
|
| 419 |
-
}
|
| 420 |
-
body.pf-dark .gradio-container h1,
|
| 421 |
-
body.pf-dark .gradio-container h2,
|
| 422 |
-
body.pf-dark .gradio-container h3,
|
| 423 |
-
body.pf-dark .gradio-container p,
|
| 424 |
-
body.pf-dark .gradio-container label,
|
| 425 |
-
body.pf-dark .gradio-container span,
|
| 426 |
-
body.pf-dark .gradio-container .prose {
|
| 427 |
-
color: #e5e7eb !important;
|
| 428 |
-
}
|
| 429 |
-
body.pf-dark .gradio-container .block,
|
| 430 |
-
body.pf-dark .gradio-container .gr-box,
|
| 431 |
-
body.pf-dark .gradio-container .gr-panel,
|
| 432 |
-
body.pf-dark .gradio-container .gr-form,
|
| 433 |
-
body.pf-dark .gradio-container .gr-group {
|
| 434 |
-
background: #111827 !important;
|
| 435 |
-
border-color: #374151 !important;
|
| 436 |
-
color: #e5e7eb !important;
|
| 437 |
-
}
|
| 438 |
-
body.pf-dark .gradio-container input,
|
| 439 |
-
body.pf-dark .gradio-container textarea,
|
| 440 |
-
body.pf-dark .gradio-container select {
|
| 441 |
-
background: #0f172a !important;
|
| 442 |
-
color: #e5e7eb !important;
|
| 443 |
-
border-color: #334155 !important;
|
| 444 |
-
}
|
| 445 |
-
body.pf-dark .gradio-container button {
|
| 446 |
-
filter: brightness(0.92);
|
| 447 |
-
}
|
| 448 |
-
`;
|
| 449 |
-
document.head.appendChild(styleEl);
|
| 450 |
-
}
|
| 451 |
-
|
| 452 |
-
document.documentElement.classList.toggle('pf-dark', !!enabled);
|
| 453 |
-
document.body.classList.toggle('pf-dark', !!enabled);
|
| 454 |
-
}
|
| 455 |
-
""",
|
| 456 |
-
)
|
| 457 |
-
|
| 458 |
run_btn.click(
|
| 459 |
fn=generate_image,
|
| 460 |
inputs=[prompt, negative_prompt, steps, guidance, width, height, seed, adult_enabled, realism_boost],
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
MODEL_ID = os.getenv("MODEL_ID", "stabilityai/sd-turbo")
|
| 16 |
+
MAX_STEPS = int(os.getenv("MAX_STEPS", "12"))
|
| 17 |
+
GPU_DURATION = max(10, min(int(os.getenv("GPU_DURATION", "20")), 30))
|
| 18 |
BUILD_TAG = os.getenv("SPACE_BUILD_TAG", datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC"))
|
| 19 |
|
| 20 |
_pipe: Optional[StableDiffusionPipeline] = None
|
|
|
|
| 325 |
with gr.Column(scale=1):
|
| 326 |
prompt = gr.Textbox(label="Prompt", placeholder="z. B. cinematic cyberpunk city at night", lines=3)
|
| 327 |
negative_prompt = gr.Textbox(label="Negative Prompt", value="blurry, low quality", lines=2)
|
| 328 |
+
steps = gr.Slider(1, MAX_STEPS, value=min(8, MAX_STEPS), step=1, label="Steps")
|
| 329 |
+
guidance = gr.Slider(0.0, 8.0, value=2.4, step=0.1, label="Guidance")
|
| 330 |
width = gr.Slider(256, 1024, value=768, step=64, label="Bildbreite")
|
| 331 |
height = gr.Slider(256, 1024, value=768, step=64, label="Bildhöhe")
|
| 332 |
seed = gr.Textbox(label="Seed", value="42")
|
| 333 |
adult_enabled = gr.Checkbox(label="Adult-Generierung erlauben (18+)", value=False)
|
| 334 |
realism_boost = gr.Checkbox(label="Realismus Boost", value=True)
|
|
|
|
|
|
|
| 335 |
style_select = gr.Dropdown(
|
| 336 |
label="Random Style",
|
| 337 |
choices=["Mix", "Cinematic", "Photo", "Anime", "Fantasy", "Studio"],
|
|
|
|
| 370 |
api_name=False,
|
| 371 |
)
|
| 372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
run_btn.click(
|
| 374 |
fn=generate_image,
|
| 375 |
inputs=[prompt, negative_prompt, steps, guidance, width, height, seed, adult_enabled, realism_boost],
|