Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files- app.py +156 -227
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -110,336 +110,270 @@ def generate_image(
|
|
| 110 |
except Exception as e:
|
| 111 |
raise gr.Error(f"Generation failed: {str(e)}")
|
| 112 |
|
| 113 |
-
# Create
|
| 114 |
apple_theme = gr.themes.Soft(
|
| 115 |
primary_hue=gr.themes.colors.blue,
|
| 116 |
secondary_hue=gr.themes.colors.slate,
|
| 117 |
neutral_hue=gr.themes.colors.gray,
|
| 118 |
spacing_size=gr.themes.sizes.spacing_lg,
|
| 119 |
radius_size=gr.themes.sizes.radius_lg,
|
| 120 |
-
text_size=gr.themes.sizes.
|
| 121 |
-
font=[gr.themes.GoogleFont("SF Pro Display"
|
| 122 |
-
font_mono=[gr.themes.GoogleFont("
|
| 123 |
).set(
|
| 124 |
-
body_background_fill='
|
| 125 |
-
body_background_fill_dark='
|
| 126 |
-
button_primary_background_fill='
|
| 127 |
-
button_primary_background_fill_hover='
|
| 128 |
-
button_primary_text_color='
|
| 129 |
-
block_background_fill='
|
| 130 |
-
block_background_fill_dark='
|
| 131 |
block_border_width='0px',
|
| 132 |
-
block_shadow='0
|
| 133 |
-
block_shadow_dark='0
|
| 134 |
-
input_background_fill='
|
| 135 |
-
input_background_fill_dark='
|
| 136 |
input_border_width='1px',
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
| 139 |
)
|
| 140 |
|
| 141 |
-
#
|
| 142 |
apple_css = """
|
| 143 |
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 144 |
-
|
| 145 |
/* Global Styles */
|
| 146 |
.gradio-container {
|
| 147 |
-
max-width:
|
| 148 |
margin: 0 auto !important;
|
| 149 |
-
padding:
|
| 150 |
-
font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif !important;
|
| 151 |
}
|
| 152 |
|
| 153 |
-
/*
|
| 154 |
-
.
|
| 155 |
text-align: center;
|
| 156 |
-
|
| 157 |
-
margin-bottom: 2rem;
|
| 158 |
-
background: rgba(255, 255, 255, 0.6);
|
| 159 |
-
backdrop-filter: blur(20px) saturate(180%);
|
| 160 |
-
-webkit-backdrop-filter: blur(20px) saturate(180%);
|
| 161 |
-
border-radius: 24px;
|
| 162 |
-
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 163 |
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
|
| 164 |
}
|
| 165 |
|
| 166 |
-
.
|
| 167 |
-
font-size:
|
| 168 |
-
font-weight:
|
| 169 |
-
|
| 170 |
-
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
margin: 0 0 1rem 0 !important;
|
| 174 |
-
letter-spacing: -0.02em;
|
| 175 |
-
line-height: 1.1 !important;
|
| 176 |
}
|
| 177 |
|
| 178 |
-
.
|
| 179 |
-
font-size:
|
| 180 |
-
color: #6b7280 !important;
|
| 181 |
font-weight: 400 !important;
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
.attribution {
|
| 187 |
-
margin-top: 1.5rem;
|
| 188 |
-
font-size: 0.95rem;
|
| 189 |
-
color: #9ca3af;
|
| 190 |
-
font-weight: 500;
|
| 191 |
}
|
| 192 |
|
| 193 |
-
.attribution
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
| 198 |
}
|
| 199 |
|
| 200 |
-
.attribution
|
| 201 |
-
color: #
|
|
|
|
| 202 |
}
|
| 203 |
|
| 204 |
/* Input Section */
|
| 205 |
-
.input-
|
| 206 |
-
background:
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
margin-bottom: 2rem;
|
| 212 |
-
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 213 |
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
|
| 214 |
-
transition: all 0.3s ease;
|
| 215 |
-
}
|
| 216 |
-
|
| 217 |
-
.input-container:hover {
|
| 218 |
-
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.1);
|
| 219 |
-
transform: translateY(-2px);
|
| 220 |
}
|
| 221 |
|
| 222 |
-
/* Textbox
|
| 223 |
textarea {
|
| 224 |
-
font-size:
|
| 225 |
-
line-height: 1.
|
| 226 |
-
border-radius:
|
| 227 |
-
border:
|
| 228 |
-
padding:
|
| 229 |
-
transition: all 0.
|
| 230 |
-
background:
|
|
|
|
| 231 |
}
|
| 232 |
|
| 233 |
textarea:focus {
|
| 234 |
-
border-color: #
|
| 235 |
-
box-shadow: 0 0 0 4px rgba(
|
| 236 |
outline: none !important;
|
| 237 |
}
|
| 238 |
|
| 239 |
textarea::placeholder {
|
| 240 |
-
color: #
|
| 241 |
-
font-weight: 400 !important;
|
| 242 |
}
|
| 243 |
|
| 244 |
-
/* Button
|
| 245 |
-
.
|
| 246 |
-
font-size:
|
| 247 |
-
font-weight:
|
| 248 |
-
padding:
|
| 249 |
-
border-radius:
|
| 250 |
-
background:
|
| 251 |
border: none !important;
|
| 252 |
-
color:
|
| 253 |
-
|
| 254 |
-
transition: all 0.
|
| 255 |
-
letter-spacing: 0.
|
| 256 |
-
|
| 257 |
-
min-width: 200px !important;
|
| 258 |
}
|
| 259 |
|
| 260 |
-
.
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
|
| 264 |
}
|
| 265 |
|
| 266 |
-
.
|
| 267 |
-
transform:
|
| 268 |
-
box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3) !important;
|
| 269 |
}
|
| 270 |
|
| 271 |
/* Output Section */
|
| 272 |
-
.output-
|
| 273 |
-
background:
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
padding: 2rem;
|
| 278 |
-
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 279 |
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
|
| 280 |
overflow: hidden;
|
| 281 |
}
|
| 282 |
|
| 283 |
-
.output-
|
| 284 |
-
border-radius:
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
}
|
| 288 |
-
|
| 289 |
-
.output-container img:hover {
|
| 290 |
-
transform: scale(1.02) !important;
|
| 291 |
}
|
| 292 |
|
| 293 |
/* Footer */
|
| 294 |
-
.footer-
|
| 295 |
text-align: center;
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
color: #
|
| 299 |
-
|
| 300 |
-
background: rgba(255, 255, 255, 0.4);
|
| 301 |
-
backdrop-filter: blur(10px);
|
| 302 |
-
border-radius: 16px;
|
| 303 |
-
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 304 |
}
|
| 305 |
|
| 306 |
-
|
| 307 |
-
margin: 0.5rem 0;
|
| 308 |
-
font-weight: 500;
|
| 309 |
-
}
|
| 310 |
-
|
| 311 |
-
.footer-highlight {
|
| 312 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 313 |
-
-webkit-background-clip: text;
|
| 314 |
-
-webkit-text-fill-color: transparent;
|
| 315 |
-
background-clip: text;
|
| 316 |
-
font-weight: 600;
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
/* Progress Bar */
|
| 320 |
.progress-bar {
|
| 321 |
-
background:
|
| 322 |
-
border-radius:
|
| 323 |
}
|
| 324 |
|
| 325 |
-
/*
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
opacity: 0;
|
| 329 |
-
transform: translateY(20px);
|
| 330 |
-
}
|
| 331 |
-
to {
|
| 332 |
-
opacity: 1;
|
| 333 |
-
transform: translateY(0);
|
| 334 |
-
}
|
| 335 |
}
|
| 336 |
|
| 337 |
-
.
|
| 338 |
-
|
| 339 |
}
|
| 340 |
|
| 341 |
-
|
| 342 |
-
.dark .
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
background: rgba(30, 30, 30, 0.8);
|
| 346 |
-
border-color: rgba(255, 255, 255, 0.1);
|
| 347 |
}
|
| 348 |
|
| 349 |
.dark textarea {
|
| 350 |
-
background:
|
| 351 |
-
border-color:
|
| 352 |
-
color: #
|
| 353 |
}
|
| 354 |
|
| 355 |
-
.dark
|
| 356 |
-
|
| 357 |
}
|
| 358 |
|
| 359 |
-
/* Responsive
|
| 360 |
-
@media (max-width:
|
| 361 |
-
.
|
| 362 |
-
font-size:
|
| 363 |
}
|
| 364 |
|
| 365 |
-
.
|
| 366 |
-
font-size:
|
| 367 |
}
|
| 368 |
|
| 369 |
.gradio-container {
|
| 370 |
-
padding:
|
| 371 |
}
|
| 372 |
|
| 373 |
-
.input-
|
| 374 |
-
.output-
|
| 375 |
-
padding:
|
| 376 |
-
}
|
| 377 |
-
|
| 378 |
-
.generate-btn button {
|
| 379 |
-
width: 100% !important;
|
| 380 |
-
padding: 0.875rem 2rem !important;
|
| 381 |
}
|
| 382 |
}
|
| 383 |
|
| 384 |
-
/*
|
| 385 |
-
|
| 386 |
-
|
| 387 |
}
|
| 388 |
"""
|
| 389 |
|
| 390 |
-
# Create the
|
| 391 |
with gr.Blocks(
|
| 392 |
-
title="Z-Image Turbo
|
|
|
|
|
|
|
| 393 |
fill_height=False,
|
| 394 |
) as demo:
|
| 395 |
|
| 396 |
-
#
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
<h1 class="
|
| 400 |
-
<p class="
|
| 401 |
-
<
|
| 402 |
-
Built with
|
| 403 |
-
</
|
| 404 |
-
|
|
|
|
| 405 |
|
| 406 |
# Input Section
|
| 407 |
-
with gr.Column(elem_classes="input-
|
| 408 |
prompt = gr.Textbox(
|
| 409 |
-
placeholder="Describe
|
| 410 |
-
lines=
|
| 411 |
-
max_lines=
|
| 412 |
label="",
|
| 413 |
show_label=False,
|
| 414 |
container=False,
|
| 415 |
-
elem_classes="prompt-input"
|
| 416 |
)
|
| 417 |
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
)
|
| 425 |
|
| 426 |
# Output Section
|
| 427 |
-
with gr.Column(elem_classes="output-
|
| 428 |
output_image = gr.Image(
|
| 429 |
type="pil",
|
| 430 |
label="",
|
| 431 |
show_label=False,
|
| 432 |
-
buttons=["download"],
|
| 433 |
container=False,
|
| 434 |
-
|
| 435 |
-
elem_classes="output-image"
|
| 436 |
)
|
| 437 |
|
| 438 |
# Footer
|
| 439 |
gr.HTML("""
|
| 440 |
-
<div class="footer-
|
| 441 |
-
<p>Powered by
|
| 442 |
-
<p>Optimized for fast, high-quality image generation</p>
|
| 443 |
</div>
|
| 444 |
""")
|
| 445 |
|
|
@@ -448,21 +382,16 @@ with gr.Blocks(
|
|
| 448 |
fn=generate_image,
|
| 449 |
inputs=prompt,
|
| 450 |
outputs=output_image,
|
| 451 |
-
api_name="generate"
|
| 452 |
)
|
| 453 |
|
| 454 |
-
# Also allow generation on Enter key
|
| 455 |
prompt.submit(
|
| 456 |
fn=generate_image,
|
| 457 |
inputs=prompt,
|
| 458 |
-
outputs=output_image
|
| 459 |
)
|
| 460 |
|
| 461 |
-
# Launch the app
|
| 462 |
if __name__ == "__main__":
|
| 463 |
demo.launch(
|
| 464 |
share=False,
|
| 465 |
show_error=True,
|
| 466 |
-
theme=apple_theme,
|
| 467 |
-
css=apple_css
|
| 468 |
)
|
|
|
|
| 110 |
except Exception as e:
|
| 111 |
raise gr.Error(f"Generation failed: {str(e)}")
|
| 112 |
|
| 113 |
+
# Create Apple-inspired theme
|
| 114 |
apple_theme = gr.themes.Soft(
|
| 115 |
primary_hue=gr.themes.colors.blue,
|
| 116 |
secondary_hue=gr.themes.colors.slate,
|
| 117 |
neutral_hue=gr.themes.colors.gray,
|
| 118 |
spacing_size=gr.themes.sizes.spacing_lg,
|
| 119 |
radius_size=gr.themes.sizes.radius_lg,
|
| 120 |
+
text_size=gr.themes.sizes.text_md,
|
| 121 |
+
font=[gr.themes.GoogleFont("Inter"), "SF Pro Display", "-apple-system", "BlinkMacSystemFont", "system-ui", "sans-serif"],
|
| 122 |
+
font_mono=[gr.themes.GoogleFont("JetBrains Mono"), "SF Mono", "ui-monospace", "monospace"],
|
| 123 |
).set(
|
| 124 |
+
body_background_fill='#f5f5f7',
|
| 125 |
+
body_background_fill_dark='#000000',
|
| 126 |
+
button_primary_background_fill='#0071e3',
|
| 127 |
+
button_primary_background_fill_hover='#0077ed',
|
| 128 |
+
button_primary_text_color='#ffffff',
|
| 129 |
+
block_background_fill='#ffffff',
|
| 130 |
+
block_background_fill_dark='#1d1d1f',
|
| 131 |
block_border_width='0px',
|
| 132 |
+
block_shadow='0 2px 12px rgba(0, 0, 0, 0.08)',
|
| 133 |
+
block_shadow_dark='0 2px 12px rgba(0, 0, 0, 0.4)',
|
| 134 |
+
input_background_fill='#ffffff',
|
| 135 |
+
input_background_fill_dark='#1d1d1f',
|
| 136 |
input_border_width='1px',
|
| 137 |
+
input_border_color='#d2d2d7',
|
| 138 |
+
input_border_color_dark='#424245',
|
| 139 |
+
input_shadow='none',
|
| 140 |
+
input_shadow_focus='0 0 0 4px rgba(0, 113, 227, 0.15)',
|
| 141 |
)
|
| 142 |
|
| 143 |
+
# Apple-style CSS
|
| 144 |
apple_css = """
|
|
|
|
|
|
|
| 145 |
/* Global Styles */
|
| 146 |
.gradio-container {
|
| 147 |
+
max-width: 980px !important;
|
| 148 |
margin: 0 auto !important;
|
| 149 |
+
padding: 48px 20px !important;
|
| 150 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', 'Roboto', sans-serif !important;
|
| 151 |
}
|
| 152 |
|
| 153 |
+
/* Header */
|
| 154 |
+
.header-container {
|
| 155 |
text-align: center;
|
| 156 |
+
margin-bottom: 48px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
}
|
| 158 |
|
| 159 |
+
.main-title {
|
| 160 |
+
font-size: 56px !important;
|
| 161 |
+
font-weight: 600 !important;
|
| 162 |
+
letter-spacing: -0.02em !important;
|
| 163 |
+
line-height: 1.07 !important;
|
| 164 |
+
color: #1d1d1f !important;
|
| 165 |
+
margin: 0 0 12px 0 !important;
|
|
|
|
|
|
|
|
|
|
| 166 |
}
|
| 167 |
|
| 168 |
+
.subtitle {
|
| 169 |
+
font-size: 21px !important;
|
|
|
|
| 170 |
font-weight: 400 !important;
|
| 171 |
+
line-height: 1.38 !important;
|
| 172 |
+
color: #6e6e73 !important;
|
| 173 |
+
margin: 0 0 24px 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
}
|
| 175 |
|
| 176 |
+
.attribution-link {
|
| 177 |
+
display: inline-block;
|
| 178 |
+
font-size: 14px !important;
|
| 179 |
+
color: #0071e3 !important;
|
| 180 |
+
text-decoration: none !important;
|
| 181 |
+
font-weight: 400 !important;
|
| 182 |
+
transition: color 0.2s ease !important;
|
| 183 |
}
|
| 184 |
|
| 185 |
+
.attribution-link:hover {
|
| 186 |
+
color: #0077ed !important;
|
| 187 |
+
text-decoration: underline !important;
|
| 188 |
}
|
| 189 |
|
| 190 |
/* Input Section */
|
| 191 |
+
.input-section {
|
| 192 |
+
background: #ffffff;
|
| 193 |
+
border-radius: 18px;
|
| 194 |
+
padding: 32px;
|
| 195 |
+
margin-bottom: 24px;
|
| 196 |
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
}
|
| 198 |
|
| 199 |
+
/* Textbox */
|
| 200 |
textarea {
|
| 201 |
+
font-size: 17px !important;
|
| 202 |
+
line-height: 1.47 !important;
|
| 203 |
+
border-radius: 12px !important;
|
| 204 |
+
border: 1px solid #d2d2d7 !important;
|
| 205 |
+
padding: 12px 16px !important;
|
| 206 |
+
transition: all 0.2s ease !important;
|
| 207 |
+
background: #ffffff !important;
|
| 208 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif !important;
|
| 209 |
}
|
| 210 |
|
| 211 |
textarea:focus {
|
| 212 |
+
border-color: #0071e3 !important;
|
| 213 |
+
box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15) !important;
|
| 214 |
outline: none !important;
|
| 215 |
}
|
| 216 |
|
| 217 |
textarea::placeholder {
|
| 218 |
+
color: #86868b !important;
|
|
|
|
| 219 |
}
|
| 220 |
|
| 221 |
+
/* Button */
|
| 222 |
+
button.primary {
|
| 223 |
+
font-size: 17px !important;
|
| 224 |
+
font-weight: 400 !important;
|
| 225 |
+
padding: 12px 32px !important;
|
| 226 |
+
border-radius: 980px !important;
|
| 227 |
+
background: #0071e3 !important;
|
| 228 |
border: none !important;
|
| 229 |
+
color: #ffffff !important;
|
| 230 |
+
min-height: 44px !important;
|
| 231 |
+
transition: all 0.2s ease !important;
|
| 232 |
+
letter-spacing: -0.01em !important;
|
| 233 |
+
cursor: pointer !important;
|
|
|
|
| 234 |
}
|
| 235 |
|
| 236 |
+
button.primary:hover {
|
| 237 |
+
background: #0077ed !important;
|
| 238 |
+
transform: scale(1.02) !important;
|
|
|
|
| 239 |
}
|
| 240 |
|
| 241 |
+
button.primary:active {
|
| 242 |
+
transform: scale(0.98) !important;
|
|
|
|
| 243 |
}
|
| 244 |
|
| 245 |
/* Output Section */
|
| 246 |
+
.output-section {
|
| 247 |
+
background: #ffffff;
|
| 248 |
+
border-radius: 18px;
|
| 249 |
+
padding: 32px;
|
| 250 |
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
|
|
|
|
|
|
|
|
| 251 |
overflow: hidden;
|
| 252 |
}
|
| 253 |
|
| 254 |
+
.output-section img {
|
| 255 |
+
border-radius: 12px !important;
|
| 256 |
+
width: 100% !important;
|
| 257 |
+
height: auto !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
}
|
| 259 |
|
| 260 |
/* Footer */
|
| 261 |
+
.footer-text {
|
| 262 |
text-align: center;
|
| 263 |
+
margin-top: 48px;
|
| 264 |
+
font-size: 14px !important;
|
| 265 |
+
color: #86868b !important;
|
| 266 |
+
line-height: 1.43 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
}
|
| 268 |
|
| 269 |
+
/* Progress */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
.progress-bar {
|
| 271 |
+
background: #0071e3 !important;
|
| 272 |
+
border-radius: 4px !important;
|
| 273 |
}
|
| 274 |
|
| 275 |
+
/* Dark Mode */
|
| 276 |
+
.dark .main-title {
|
| 277 |
+
color: #f5f5f7 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
}
|
| 279 |
|
| 280 |
+
.dark .subtitle {
|
| 281 |
+
color: #a1a1a6 !important;
|
| 282 |
}
|
| 283 |
|
| 284 |
+
.dark .input-section,
|
| 285 |
+
.dark .output-section {
|
| 286 |
+
background: #1d1d1f;
|
| 287 |
+
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
|
|
|
|
|
|
|
| 288 |
}
|
| 289 |
|
| 290 |
.dark textarea {
|
| 291 |
+
background: #1d1d1f !important;
|
| 292 |
+
border-color: #424245 !important;
|
| 293 |
+
color: #f5f5f7 !important;
|
| 294 |
}
|
| 295 |
|
| 296 |
+
.dark textarea::placeholder {
|
| 297 |
+
color: #86868b !important;
|
| 298 |
}
|
| 299 |
|
| 300 |
+
/* Responsive */
|
| 301 |
+
@media (max-width: 734px) {
|
| 302 |
+
.main-title {
|
| 303 |
+
font-size: 40px !important;
|
| 304 |
}
|
| 305 |
|
| 306 |
+
.subtitle {
|
| 307 |
+
font-size: 19px !important;
|
| 308 |
}
|
| 309 |
|
| 310 |
.gradio-container {
|
| 311 |
+
padding: 32px 16px !important;
|
| 312 |
}
|
| 313 |
|
| 314 |
+
.input-section,
|
| 315 |
+
.output-section {
|
| 316 |
+
padding: 24px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
}
|
| 318 |
}
|
| 319 |
|
| 320 |
+
/* Remove default Gradio styling */
|
| 321 |
+
.contain {
|
| 322 |
+
padding: 0 !important;
|
| 323 |
}
|
| 324 |
"""
|
| 325 |
|
| 326 |
+
# Create the interface
|
| 327 |
with gr.Blocks(
|
| 328 |
+
title="Z-Image Turbo",
|
| 329 |
+
theme=apple_theme,
|
| 330 |
+
css=apple_css,
|
| 331 |
fill_height=False,
|
| 332 |
) as demo:
|
| 333 |
|
| 334 |
+
# Header
|
| 335 |
+
gr.HTML("""
|
| 336 |
+
<div class="header-container">
|
| 337 |
+
<h1 class="main-title">Z-Image Turbo</h1>
|
| 338 |
+
<p class="subtitle">Transform your ideas into stunning visuals with AI</p>
|
| 339 |
+
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="attribution-link">
|
| 340 |
+
Built with anycoder
|
| 341 |
+
</a>
|
| 342 |
+
</div>
|
| 343 |
+
""")
|
| 344 |
|
| 345 |
# Input Section
|
| 346 |
+
with gr.Column(elem_classes="input-section"):
|
| 347 |
prompt = gr.Textbox(
|
| 348 |
+
placeholder="Describe the image you want to create...",
|
| 349 |
+
lines=3,
|
| 350 |
+
max_lines=6,
|
| 351 |
label="",
|
| 352 |
show_label=False,
|
| 353 |
container=False,
|
|
|
|
| 354 |
)
|
| 355 |
|
| 356 |
+
generate_btn = gr.Button(
|
| 357 |
+
"Generate",
|
| 358 |
+
variant="primary",
|
| 359 |
+
size="lg",
|
| 360 |
+
elem_classes="primary"
|
| 361 |
+
)
|
|
|
|
| 362 |
|
| 363 |
# Output Section
|
| 364 |
+
with gr.Column(elem_classes="output-section"):
|
| 365 |
output_image = gr.Image(
|
| 366 |
type="pil",
|
| 367 |
label="",
|
| 368 |
show_label=False,
|
|
|
|
| 369 |
container=False,
|
| 370 |
+
show_download_button=True,
|
|
|
|
| 371 |
)
|
| 372 |
|
| 373 |
# Footer
|
| 374 |
gr.HTML("""
|
| 375 |
+
<div class="footer-text">
|
| 376 |
+
<p>Powered by Z-Image Turbo from Tongyi-MAI</p>
|
|
|
|
| 377 |
</div>
|
| 378 |
""")
|
| 379 |
|
|
|
|
| 382 |
fn=generate_image,
|
| 383 |
inputs=prompt,
|
| 384 |
outputs=output_image,
|
|
|
|
| 385 |
)
|
| 386 |
|
|
|
|
| 387 |
prompt.submit(
|
| 388 |
fn=generate_image,
|
| 389 |
inputs=prompt,
|
| 390 |
+
outputs=output_image,
|
| 391 |
)
|
| 392 |
|
|
|
|
| 393 |
if __name__ == "__main__":
|
| 394 |
demo.launch(
|
| 395 |
share=False,
|
| 396 |
show_error=True,
|
|
|
|
|
|
|
| 397 |
)
|
requirements.txt
CHANGED
|
@@ -11,4 +11,4 @@ gradio
|
|
| 11 |
requests
|
| 12 |
Pillow
|
| 13 |
numpy
|
| 14 |
-
scipy
|
|
|
|
| 11 |
requests
|
| 12 |
Pillow
|
| 13 |
numpy
|
| 14 |
+
scipy
|