Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -89,124 +89,232 @@ def update_dimensions_from_image(image_list):
|
|
| 89 |
css = """
|
| 90 |
/* Glassmorphism Style */
|
| 91 |
body, .gradio-container {
|
| 92 |
-
background: linear-gradient(135deg, #
|
| 93 |
min-height: 100vh;
|
| 94 |
}
|
| 95 |
|
| 96 |
#col-container {
|
| 97 |
margin: 0 auto;
|
| 98 |
-
max-width:
|
| 99 |
-
padding: 20px;
|
| 100 |
}
|
| 101 |
|
| 102 |
-
|
| 103 |
-
.
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
backdrop-filter: blur(20px) !important;
|
| 106 |
-webkit-backdrop-filter: blur(20px) !important;
|
| 107 |
-
border: 1px solid rgba(255, 255, 255, 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
border-radius: 16px !important;
|
| 109 |
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2) !important;
|
| 110 |
}
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
color: white !important;
|
| 116 |
-
font-
|
|
|
|
|
|
|
| 117 |
transition: all 0.3s ease !important;
|
| 118 |
}
|
| 119 |
|
| 120 |
-
.
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4) !important;
|
| 124 |
}
|
| 125 |
|
| 126 |
-
textarea
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
color: white !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
}
|
| 132 |
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
-
|
| 138 |
color: rgba(255, 255, 255, 0.9) !important;
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
| 144 |
}
|
| 145 |
|
| 146 |
.gallery-container img {
|
| 147 |
object-fit: contain;
|
| 148 |
-
border-radius:
|
| 149 |
}
|
| 150 |
|
|
|
|
| 151 |
input[type="range"] {
|
| 152 |
accent-color: #667eea !important;
|
| 153 |
}
|
| 154 |
|
| 155 |
-
.
|
| 156 |
-
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
}
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
::-webkit-scrollbar {
|
| 161 |
-
width:
|
| 162 |
}
|
| 163 |
|
| 164 |
::-webkit-scrollbar-track {
|
| 165 |
-
background: rgba(255, 255, 255, 0.
|
| 166 |
-
border-radius:
|
| 167 |
}
|
| 168 |
|
| 169 |
::-webkit-scrollbar-thumb {
|
| 170 |
-
background: rgba(255, 255, 255, 0.
|
| 171 |
-
border-radius:
|
| 172 |
}
|
| 173 |
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
}
|
| 178 |
"""
|
| 179 |
|
| 180 |
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
| 181 |
|
| 182 |
with gr.Column(elem_id="col-container"):
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
with gr.Row():
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
|
|
|
| 197 |
|
| 198 |
-
with gr.Accordion("📷 Input Images", open=
|
| 199 |
input_images = gr.Gallery(
|
| 200 |
-
label="
|
| 201 |
type="pil",
|
| 202 |
columns=3,
|
| 203 |
rows=1,
|
| 204 |
elem_classes="gallery-container"
|
| 205 |
)
|
| 206 |
|
| 207 |
-
with gr.Accordion("⚙️ Settings", open=False):
|
| 208 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
|
| 209 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
| 210 |
|
| 211 |
with gr.Row():
|
| 212 |
width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
|
@@ -215,9 +323,10 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 215 |
with gr.Row():
|
| 216 |
num_inference_steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=50)
|
| 217 |
guidance_scale = gr.Slider(label="Guidance", minimum=0.0, maximum=10.0, step=0.1, value=1.5)
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
| 221 |
|
| 222 |
input_images.upload(
|
| 223 |
fn=update_dimensions_from_image,
|
|
@@ -232,4 +341,4 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
|
| 232 |
outputs=[result, seed]
|
| 233 |
)
|
| 234 |
|
| 235 |
-
demo.launch(
|
|
|
|
| 89 |
css = """
|
| 90 |
/* Glassmorphism Style */
|
| 91 |
body, .gradio-container {
|
| 92 |
+
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%) !important;
|
| 93 |
min-height: 100vh;
|
| 94 |
}
|
| 95 |
|
| 96 |
#col-container {
|
| 97 |
margin: 0 auto;
|
| 98 |
+
max-width: 1100px;
|
| 99 |
+
padding: 30px 20px;
|
| 100 |
}
|
| 101 |
|
| 102 |
+
/* Header Section */
|
| 103 |
+
.header-section {
|
| 104 |
+
text-align: center;
|
| 105 |
+
margin-bottom: 30px;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.badge-container {
|
| 109 |
+
display: flex;
|
| 110 |
+
justify-content: center;
|
| 111 |
+
margin-bottom: 15px;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.title-text {
|
| 115 |
+
font-size: 2.5rem !important;
|
| 116 |
+
font-weight: 700 !important;
|
| 117 |
+
background: linear-gradient(135deg, #667eea, #764ba2, #f093fb) !important;
|
| 118 |
+
-webkit-background-clip: text !important;
|
| 119 |
+
-webkit-text-fill-color: transparent !important;
|
| 120 |
+
background-clip: text !important;
|
| 121 |
+
margin: 10px 0 5px 0 !important;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.subtitle-text {
|
| 125 |
+
color: rgba(255, 255, 255, 0.7) !important;
|
| 126 |
+
font-size: 1rem !important;
|
| 127 |
+
margin: 0 !important;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/* Glass Cards */
|
| 131 |
+
.glass-card {
|
| 132 |
+
background: rgba(255, 255, 255, 0.08) !important;
|
| 133 |
backdrop-filter: blur(20px) !important;
|
| 134 |
-webkit-backdrop-filter: blur(20px) !important;
|
| 135 |
+
border: 1px solid rgba(255, 255, 255, 0.15) !important;
|
| 136 |
+
border-radius: 20px !important;
|
| 137 |
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
|
| 138 |
+
padding: 20px !important;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
.gr-panel, .gr-box, .gr-form, .block, .form {
|
| 142 |
+
background: rgba(255, 255, 255, 0.05) !important;
|
| 143 |
+
backdrop-filter: blur(15px) !important;
|
| 144 |
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 145 |
border-radius: 16px !important;
|
|
|
|
| 146 |
}
|
| 147 |
|
| 148 |
+
/* Prompt Input */
|
| 149 |
+
.prompt-container textarea {
|
| 150 |
+
background: rgba(255, 255, 255, 0.08) !important;
|
| 151 |
+
border: 2px solid rgba(255, 255, 255, 0.15) !important;
|
| 152 |
+
border-radius: 14px !important;
|
| 153 |
color: white !important;
|
| 154 |
+
font-size: 1rem !important;
|
| 155 |
+
padding: 15px !important;
|
| 156 |
+
min-height: 80px !important;
|
| 157 |
transition: all 0.3s ease !important;
|
| 158 |
}
|
| 159 |
|
| 160 |
+
.prompt-container textarea:focus {
|
| 161 |
+
border-color: rgba(102, 126, 234, 0.6) !important;
|
| 162 |
+
box-shadow: 0 0 20px rgba(102, 126, 234, 0.3) !important;
|
|
|
|
| 163 |
}
|
| 164 |
|
| 165 |
+
.prompt-container textarea::placeholder {
|
| 166 |
+
color: rgba(255, 255, 255, 0.4) !important;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/* Generate Button */
|
| 170 |
+
.generate-btn {
|
| 171 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
| 172 |
+
border: none !important;
|
| 173 |
+
border-radius: 14px !important;
|
| 174 |
color: white !important;
|
| 175 |
+
font-weight: 600 !important;
|
| 176 |
+
font-size: 1.1rem !important;
|
| 177 |
+
padding: 14px 30px !important;
|
| 178 |
+
transition: all 0.3s ease !important;
|
| 179 |
+
box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4) !important;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.generate-btn:hover {
|
| 183 |
+
transform: translateY(-3px) !important;
|
| 184 |
+
box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6) !important;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
/* Result Image */
|
| 188 |
+
.result-container {
|
| 189 |
+
background: rgba(255, 255, 255, 0.05) !important;
|
| 190 |
+
border-radius: 20px !important;
|
| 191 |
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 192 |
+
overflow: hidden !important;
|
| 193 |
+
min-height: 400px !important;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.result-container img {
|
| 197 |
+
border-radius: 16px !important;
|
| 198 |
}
|
| 199 |
|
| 200 |
+
/* Accordion */
|
| 201 |
+
.gr-accordion {
|
| 202 |
+
background: rgba(255, 255, 255, 0.05) !important;
|
| 203 |
+
border: 1px solid rgba(255, 255, 255, 0.1) !important;
|
| 204 |
+
border-radius: 14px !important;
|
| 205 |
+
margin-top: 15px !important;
|
| 206 |
}
|
| 207 |
|
| 208 |
+
.gr-accordion-header {
|
| 209 |
color: rgba(255, 255, 255, 0.9) !important;
|
| 210 |
+
font-weight: 500 !important;
|
| 211 |
}
|
| 212 |
|
| 213 |
+
/* Gallery */
|
| 214 |
+
.gallery-container {
|
| 215 |
+
background: rgba(255, 255, 255, 0.03) !important;
|
| 216 |
+
border-radius: 12px !important;
|
| 217 |
+
padding: 10px !important;
|
| 218 |
}
|
| 219 |
|
| 220 |
.gallery-container img {
|
| 221 |
object-fit: contain;
|
| 222 |
+
border-radius: 10px !important;
|
| 223 |
}
|
| 224 |
|
| 225 |
+
/* Sliders & Inputs */
|
| 226 |
input[type="range"] {
|
| 227 |
accent-color: #667eea !important;
|
| 228 |
}
|
| 229 |
|
| 230 |
+
label, .label-wrap, span {
|
| 231 |
+
color: rgba(255, 255, 255, 0.85) !important;
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
input[type="number"] {
|
| 235 |
+
background: rgba(255, 255, 255, 0.08) !important;
|
| 236 |
+
border: 1px solid rgba(255, 255, 255, 0.15) !important;
|
| 237 |
+
border-radius: 8px !important;
|
| 238 |
+
color: white !important;
|
| 239 |
}
|
| 240 |
|
| 241 |
+
/* Checkbox */
|
| 242 |
+
input[type="checkbox"] {
|
| 243 |
+
accent-color: #667eea !important;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
/* Scrollbar */
|
| 247 |
::-webkit-scrollbar {
|
| 248 |
+
width: 6px;
|
| 249 |
}
|
| 250 |
|
| 251 |
::-webkit-scrollbar-track {
|
| 252 |
+
background: rgba(255, 255, 255, 0.05);
|
| 253 |
+
border-radius: 3px;
|
| 254 |
}
|
| 255 |
|
| 256 |
::-webkit-scrollbar-thumb {
|
| 257 |
+
background: rgba(255, 255, 255, 0.2);
|
| 258 |
+
border-radius: 3px;
|
| 259 |
}
|
| 260 |
|
| 261 |
+
/* Row Balance */
|
| 262 |
+
.main-row {
|
| 263 |
+
gap: 25px !important;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
.input-column {
|
| 267 |
+
flex: 1 !important;
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
.output-column {
|
| 271 |
+
flex: 1.2 !important;
|
| 272 |
}
|
| 273 |
"""
|
| 274 |
|
| 275 |
with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
|
| 276 |
|
| 277 |
with gr.Column(elem_id="col-container"):
|
| 278 |
+
# Header with centered badge
|
| 279 |
+
gr.HTML("""
|
| 280 |
+
<div class="header-section">
|
| 281 |
+
<div class="badge-container">
|
| 282 |
+
<a href="https://www.humangen.ai" target="_blank">
|
| 283 |
+
<img src="https://img.shields.io/static/v1?label=Free%20AI%20HUB&message=humangen.ai&color=%230000ff&labelColor=%23800080&logo=huggingface&logoColor=white&style=for-the-badge" alt="badge">
|
| 284 |
+
</a>
|
| 285 |
+
</div>
|
| 286 |
+
<h1 class="title-text">✨ GLM-Image Generator</h1>
|
| 287 |
+
<p class="subtitle-text">9B hybrid AI model for text-accurate image generation</p>
|
| 288 |
+
</div>
|
| 289 |
+
""")
|
| 290 |
|
| 291 |
+
with gr.Row(elem_classes="main-row"):
|
| 292 |
+
# Left Column - Input
|
| 293 |
+
with gr.Column(elem_classes="input-column"):
|
| 294 |
+
with gr.Group(elem_classes="glass-card"):
|
| 295 |
+
prompt = gr.Text(
|
| 296 |
+
label="Prompt",
|
| 297 |
+
show_label=False,
|
| 298 |
+
max_lines=4,
|
| 299 |
+
placeholder="✍️ Describe the image you want to create...",
|
| 300 |
+
container=False,
|
| 301 |
+
elem_classes="prompt-container"
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
run_button = gr.Button("🎨 Generate Image", variant="primary", elem_classes="generate-btn")
|
| 305 |
|
| 306 |
+
with gr.Accordion("📷 Input Images (Optional)", open=False):
|
| 307 |
input_images = gr.Gallery(
|
| 308 |
+
label="Upload for image-to-image mode",
|
| 309 |
type="pil",
|
| 310 |
columns=3,
|
| 311 |
rows=1,
|
| 312 |
elem_classes="gallery-container"
|
| 313 |
)
|
| 314 |
|
| 315 |
+
with gr.Accordion("⚙️ Advanced Settings", open=False):
|
| 316 |
seed = gr.Slider(label="Seed", minimum=0, maximum=MAX_SEED, step=1, value=42)
|
| 317 |
+
randomize_seed = gr.Checkbox(label="🎲 Randomize seed", value=True)
|
| 318 |
|
| 319 |
with gr.Row():
|
| 320 |
width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=1024)
|
|
|
|
| 323 |
with gr.Row():
|
| 324 |
num_inference_steps = gr.Slider(label="Steps", minimum=1, maximum=100, step=1, value=50)
|
| 325 |
guidance_scale = gr.Slider(label="Guidance", minimum=0.0, maximum=10.0, step=0.1, value=1.5)
|
| 326 |
+
|
| 327 |
+
# Right Column - Output
|
| 328 |
+
with gr.Column(elem_classes="output-column"):
|
| 329 |
+
result = gr.Image(label="Generated Image", show_label=False, elem_classes="result-container")
|
| 330 |
|
| 331 |
input_images.upload(
|
| 332 |
fn=update_dimensions_from_image,
|
|
|
|
| 341 |
outputs=[result, seed]
|
| 342 |
)
|
| 343 |
|
| 344 |
+
demo.launch()
|