Spaces:
Running on Zero
Running on Zero
refactor: remove Prompt Enhancer support and update UI layout and styling
Browse files- app.py +2 -3
- index.html +30 -27
app.py
CHANGED
|
@@ -28,7 +28,7 @@ app = Server()
|
|
| 28 |
|
| 29 |
@app.api()
|
| 30 |
@spaces.GPU(duration=120)
|
| 31 |
-
def generate_image(prompt: str, width: int = 1024, height: int = 1024, guidance_scale: float = 1.0, num_inference_steps: int = 8
|
| 32 |
"""Generate an image using ERNIE-Image-Turbo."""
|
| 33 |
print(f"Endpoint triggered! Prompt: {prompt}, width: {width}, height: {height}", flush=True)
|
| 34 |
|
|
@@ -38,8 +38,7 @@ def generate_image(prompt: str, width: int = 1024, height: int = 1024, guidance_
|
|
| 38 |
height=height,
|
| 39 |
width=width,
|
| 40 |
num_inference_steps=num_inference_steps,
|
| 41 |
-
guidance_scale=guidance_scale
|
| 42 |
-
use_pe=use_pe
|
| 43 |
).images[0]
|
| 44 |
|
| 45 |
# Save to a temporary unique file
|
|
|
|
| 28 |
|
| 29 |
@app.api()
|
| 30 |
@spaces.GPU(duration=120)
|
| 31 |
+
def generate_image(prompt: str, width: int = 1024, height: int = 1024, guidance_scale: float = 1.0, num_inference_steps: int = 8) -> FileData:
|
| 32 |
"""Generate an image using ERNIE-Image-Turbo."""
|
| 33 |
print(f"Endpoint triggered! Prompt: {prompt}, width: {width}, height: {height}", flush=True)
|
| 34 |
|
|
|
|
| 38 |
height=height,
|
| 39 |
width=width,
|
| 40 |
num_inference_steps=num_inference_steps,
|
| 41 |
+
guidance_scale=guidance_scale
|
|
|
|
| 42 |
).images[0]
|
| 43 |
|
| 44 |
# Save to a temporary unique file
|
index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>ERNIE Image Turbo
|
| 7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
|
@@ -47,25 +47,26 @@
|
|
| 47 |
display: flex;
|
| 48 |
width: 100%;
|
| 49 |
height: 100vh;
|
| 50 |
-
padding:
|
| 51 |
-
gap:
|
| 52 |
}
|
| 53 |
|
| 54 |
/* ----- SIDEBAR CONTROLS ----- */
|
| 55 |
.sidebar {
|
| 56 |
-
width:
|
| 57 |
background: var(--glass-bg);
|
| 58 |
-
backdrop-filter: blur(
|
| 59 |
-
-webkit-backdrop-filter: blur(
|
| 60 |
border: 1px solid var(--glass-border);
|
| 61 |
-
border-radius:
|
| 62 |
-
padding:
|
| 63 |
display: flex;
|
| 64 |
flex-direction: column;
|
| 65 |
gap: 1.5rem;
|
| 66 |
box-shadow: var(--glass-shadow);
|
| 67 |
overflow-y: auto;
|
| 68 |
flex-shrink: 0;
|
|
|
|
| 69 |
}
|
| 70 |
|
| 71 |
/* Custom Scrollbar for Sidebar */
|
|
@@ -86,7 +87,7 @@
|
|
| 86 |
|
| 87 |
.header h1 {
|
| 88 |
font-family: 'Outfit', sans-serif;
|
| 89 |
-
font-size:
|
| 90 |
font-weight: 700;
|
| 91 |
background: linear-gradient(135deg, #a5b4fc 0%, #fbcfe8 100%);
|
| 92 |
-webkit-background-clip: text;
|
|
@@ -266,17 +267,18 @@
|
|
| 266 |
.workspace {
|
| 267 |
flex: 1;
|
| 268 |
background: var(--glass-bg);
|
| 269 |
-
backdrop-filter: blur(
|
| 270 |
-
-webkit-backdrop-filter: blur(
|
| 271 |
border: 1px solid var(--glass-border);
|
| 272 |
-
border-radius:
|
| 273 |
display: flex;
|
| 274 |
align-items: center;
|
| 275 |
justify-content: center;
|
| 276 |
position: relative;
|
| 277 |
box-shadow: var(--glass-shadow);
|
| 278 |
overflow: hidden;
|
| 279 |
-
padding:
|
|
|
|
| 280 |
}
|
| 281 |
|
| 282 |
.image-container {
|
|
@@ -440,12 +442,21 @@
|
|
| 440 |
|
| 441 |
@media (max-width: 1024px) {
|
| 442 |
main {
|
| 443 |
-
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
| 444 |
}
|
| 445 |
.sidebar {
|
| 446 |
width: 100%;
|
| 447 |
-
height:
|
| 448 |
-
max-height:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 449 |
}
|
| 450 |
}
|
| 451 |
</style>
|
|
@@ -456,8 +467,8 @@
|
|
| 456 |
<!-- Sidebar Controls -->
|
| 457 |
<aside class="sidebar">
|
| 458 |
<div class="header">
|
| 459 |
-
<h1>ERNIE
|
| 460 |
-
<p>
|
| 461 |
</div>
|
| 462 |
|
| 463 |
<div class="control-group">
|
|
@@ -497,12 +508,6 @@
|
|
| 497 |
<input type="range" id="guidance" min="0.0" max="5.0" step="0.1" value="1.0">
|
| 498 |
</div>
|
| 499 |
|
| 500 |
-
<label class="checkbox-container">
|
| 501 |
-
<input type="checkbox" id="use-pe" checked>
|
| 502 |
-
<div class="checkmark"><i class="fas fa-check"></i></div>
|
| 503 |
-
Use Prompt Enhancer
|
| 504 |
-
</label>
|
| 505 |
-
|
| 506 |
<button class="btn-generate" id="generate-btn">
|
| 507 |
<i class="fas fa-wand-magic-sparkles"></i>
|
| 508 |
Generate Image
|
|
@@ -550,7 +555,6 @@
|
|
| 550 |
const stepsVal = document.getElementById('steps-val');
|
| 551 |
const guidanceSlider = document.getElementById('guidance');
|
| 552 |
const guidanceVal = document.getElementById('guidance-val');
|
| 553 |
-
const peCheckbox = document.getElementById('use-pe');
|
| 554 |
|
| 555 |
const generateBtn = document.getElementById('generate-btn');
|
| 556 |
const resultImage = document.getElementById('result-image');
|
|
@@ -606,8 +610,7 @@
|
|
| 606 |
width: parseInt(widthSlider.value),
|
| 607 |
height: parseInt(heightSlider.value),
|
| 608 |
guidance_scale: parseFloat(guidanceSlider.value),
|
| 609 |
-
num_inference_steps: parseInt(stepsSlider.value)
|
| 610 |
-
use_pe: peCheckbox.checked
|
| 611 |
};
|
| 612 |
|
| 613 |
// Call endpoint
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ERNIE Image Turbo</title>
|
| 7 |
<link rel="preconnect" href="https://fonts.googleapis.com">
|
| 8 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
| 9 |
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
|
|
|
| 47 |
display: flex;
|
| 48 |
width: 100%;
|
| 49 |
height: 100vh;
|
| 50 |
+
padding: 1rem;
|
| 51 |
+
gap: 1rem;
|
| 52 |
}
|
| 53 |
|
| 54 |
/* ----- SIDEBAR CONTROLS ----- */
|
| 55 |
.sidebar {
|
| 56 |
+
width: 360px;
|
| 57 |
background: var(--glass-bg);
|
| 58 |
+
backdrop-filter: blur(20px);
|
| 59 |
+
-webkit-backdrop-filter: blur(20px);
|
| 60 |
border: 1px solid var(--glass-border);
|
| 61 |
+
border-radius: 24px;
|
| 62 |
+
padding: 1.5rem;
|
| 63 |
display: flex;
|
| 64 |
flex-direction: column;
|
| 65 |
gap: 1.5rem;
|
| 66 |
box-shadow: var(--glass-shadow);
|
| 67 |
overflow-y: auto;
|
| 68 |
flex-shrink: 0;
|
| 69 |
+
z-index: 2;
|
| 70 |
}
|
| 71 |
|
| 72 |
/* Custom Scrollbar for Sidebar */
|
|
|
|
| 87 |
|
| 88 |
.header h1 {
|
| 89 |
font-family: 'Outfit', sans-serif;
|
| 90 |
+
font-size: 1.8rem;
|
| 91 |
font-weight: 700;
|
| 92 |
background: linear-gradient(135deg, #a5b4fc 0%, #fbcfe8 100%);
|
| 93 |
-webkit-background-clip: text;
|
|
|
|
| 267 |
.workspace {
|
| 268 |
flex: 1;
|
| 269 |
background: var(--glass-bg);
|
| 270 |
+
backdrop-filter: blur(20px);
|
| 271 |
+
-webkit-backdrop-filter: blur(20px);
|
| 272 |
border: 1px solid var(--glass-border);
|
| 273 |
+
border-radius: 24px;
|
| 274 |
display: flex;
|
| 275 |
align-items: center;
|
| 276 |
justify-content: center;
|
| 277 |
position: relative;
|
| 278 |
box-shadow: var(--glass-shadow);
|
| 279 |
overflow: hidden;
|
| 280 |
+
padding: 1rem;
|
| 281 |
+
z-index: 1;
|
| 282 |
}
|
| 283 |
|
| 284 |
.image-container {
|
|
|
|
| 442 |
|
| 443 |
@media (max-width: 1024px) {
|
| 444 |
main {
|
| 445 |
+
flex-direction: column-reverse; /* Image on top, controls on bottom */
|
| 446 |
+
padding: 0.5rem;
|
| 447 |
+
gap: 0.5rem;
|
| 448 |
+
height: 100dvh;
|
| 449 |
}
|
| 450 |
.sidebar {
|
| 451 |
width: 100%;
|
| 452 |
+
height: 50vh;
|
| 453 |
+
max-height: none;
|
| 454 |
+
border-radius: 20px 20px 0 0;
|
| 455 |
+
padding-bottom: 2rem; /* Give breathing room at bottom */
|
| 456 |
+
}
|
| 457 |
+
.workspace {
|
| 458 |
+
height: 50vh;
|
| 459 |
+
border-radius: 0 0 20px 20px;
|
| 460 |
}
|
| 461 |
}
|
| 462 |
</style>
|
|
|
|
| 467 |
<!-- Sidebar Controls -->
|
| 468 |
<aside class="sidebar">
|
| 469 |
<div class="header">
|
| 470 |
+
<h1>ERNIE Image Turbo</h1>
|
| 471 |
+
<p>High-Fidelity Gen-AI</p>
|
| 472 |
</div>
|
| 473 |
|
| 474 |
<div class="control-group">
|
|
|
|
| 508 |
<input type="range" id="guidance" min="0.0" max="5.0" step="0.1" value="1.0">
|
| 509 |
</div>
|
| 510 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
<button class="btn-generate" id="generate-btn">
|
| 512 |
<i class="fas fa-wand-magic-sparkles"></i>
|
| 513 |
Generate Image
|
|
|
|
| 555 |
const stepsVal = document.getElementById('steps-val');
|
| 556 |
const guidanceSlider = document.getElementById('guidance');
|
| 557 |
const guidanceVal = document.getElementById('guidance-val');
|
|
|
|
| 558 |
|
| 559 |
const generateBtn = document.getElementById('generate-btn');
|
| 560 |
const resultImage = document.getElementById('result-image');
|
|
|
|
| 610 |
width: parseInt(widthSlider.value),
|
| 611 |
height: parseInt(heightSlider.value),
|
| 612 |
guidance_scale: parseFloat(guidanceSlider.value),
|
| 613 |
+
num_inference_steps: parseInt(stepsSlider.value)
|
|
|
|
| 614 |
};
|
| 615 |
|
| 616 |
// Call endpoint
|