Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -281,8 +281,70 @@ class Stage(Enum):
|
|
| 281 |
SECOND_STAGE = "refiner"
|
| 282 |
FULL = "full"
|
| 283 |
|
| 284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
text-align: center;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
}
|
| 287 |
|
| 288 |
#share-btn-container {
|
|
@@ -292,8 +354,8 @@ css="""#disp_image {
|
|
| 292 |
justify-content: center;
|
| 293 |
align-items: center;
|
| 294 |
border-radius: 9999px !important;
|
| 295 |
-
max-width:
|
| 296 |
-
margin
|
| 297 |
}
|
| 298 |
|
| 299 |
#share-btn-container > div {
|
|
@@ -341,97 +403,39 @@ css="""#disp_image {
|
|
| 341 |
background: #1565c0;
|
| 342 |
}
|
| 343 |
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
margin: 0;
|
| 348 |
-
padding: 0;
|
| 349 |
-
display: flex;
|
| 350 |
-
flex-direction: column;
|
| 351 |
-
justify-content: center;
|
| 352 |
-
align-items: center;
|
| 353 |
-
min-height: 100vh;
|
| 354 |
-
color: #333;
|
| 355 |
-
}
|
| 356 |
-
|
| 357 |
-
.custom-button {
|
| 358 |
-
background: linear-gradient(271.15deg, #00C7E2 0.27%, #00CC6A 48.52%, #70FF00 102.07%);
|
| 359 |
-
font-size: 30px;
|
| 360 |
-
color: white;
|
| 361 |
-
padding: 10px 20px;
|
| 362 |
-
border: none;
|
| 363 |
-
border-radius: 5px;
|
| 364 |
-
cursor: pointer;
|
| 365 |
-
transition: opacity 0.3s ease;
|
| 366 |
-
}
|
| 367 |
-
|
| 368 |
-
.custom-button:hover {
|
| 369 |
-
opacity: 0.8;
|
| 370 |
-
}
|
| 371 |
-
|
| 372 |
-
.custom-title {
|
| 373 |
-
font-size: 36px;
|
| 374 |
-
background: linear-gradient(271.15deg, #00C7E2 0.27%, #12C06D 102.07%);
|
| 375 |
-
-webkit-background-clip: text;
|
| 376 |
-
-webkit-text-fill-color: transparent;
|
| 377 |
-
font-weight: bold;
|
| 378 |
-
text-align: center;
|
| 379 |
-
margin-bottom: 20px;
|
| 380 |
-
}
|
| 381 |
-
|
| 382 |
-
h1 {
|
| 383 |
-
color: #222222;
|
| 384 |
-
}
|
| 385 |
-
|
| 386 |
-
a {
|
| 387 |
-
color: #4a90e2;
|
| 388 |
-
text-decoration: none;
|
| 389 |
-
font-weight: bold;
|
| 390 |
-
}
|
| 391 |
-
|
| 392 |
-
a:hover {
|
| 393 |
-
text-decoration: underline;
|
| 394 |
-
}
|
| 395 |
-
|
| 396 |
-
.emoji {
|
| 397 |
-
font-size: 1.5em;
|
| 398 |
}
|
| 399 |
|
|
|
|
| 400 |
@media (max-width: 768px) {
|
| 401 |
.custom-button {
|
| 402 |
-
font-size:
|
| 403 |
-
padding:
|
| 404 |
}
|
| 405 |
|
| 406 |
.custom-title {
|
| 407 |
-
font-size:
|
| 408 |
-
}
|
| 409 |
-
|
| 410 |
-
#disp_image, .container {
|
| 411 |
-
padding: 0 1rem;
|
| 412 |
}
|
| 413 |
|
| 414 |
-
h1 {
|
| 415 |
-
font-size:
|
| 416 |
}
|
| 417 |
}
|
| 418 |
|
| 419 |
@media (max-width: 480px) {
|
| 420 |
.custom-button {
|
| 421 |
-
font-size:
|
| 422 |
-
padding:
|
| 423 |
}
|
| 424 |
|
| 425 |
.custom-title {
|
| 426 |
-
font-size:
|
| 427 |
-
}
|
| 428 |
-
|
| 429 |
-
.container {
|
| 430 |
-
padding: 0 0.5rem;
|
| 431 |
}
|
| 432 |
|
| 433 |
-
h1 {
|
| 434 |
-
font-size:
|
| 435 |
}
|
| 436 |
|
| 437 |
#share-btn-container {
|
|
@@ -439,72 +443,64 @@ a:hover {
|
|
| 439 |
padding: 0.5rem;
|
| 440 |
}
|
| 441 |
}
|
| 442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
block = gr.Blocks(css=css, title="## F.ai Fuzer").queue()
|
| 444 |
with block:
|
| 445 |
-
|
|
|
|
| 446 |
gr.HTML('''
|
| 447 |
-
|
| 448 |
<div class="container">
|
| 449 |
<center><h1 class="custom-title">Fotographer.ai Fuzer v0.1: Transcending image Generation Control🎨</h1></center>
|
| 450 |
-
<h2>Control Your Creativity with Unmatched Precision:
|
| 451 |
<p>Fotographer.ai Fuzer v0.1 empowers you to seamlessly blend foreground elements with any background, while maintaining the shape and style consistency of the foreground. This tool transcends traditional image generation methods by giving you unprecedented control over the final output.</p>
|
| 452 |
-
|
| 453 |
<h2>Step-by-Step Instructions</h2>
|
| 454 |
<p>Follow these instructions to control the generation of backgrounds while keeping the foreground's shape and style consistent:</p>
|
| 455 |
<ul>
|
| 456 |
-
<li>
|
| 457 |
-
<span class="emoji">📝</span>
|
| 458 |
-
<strong>Step 1: Describe the Background</strong>
|
| 459 |
<p>Start by providing a detailed description of the background you want to create.</p>
|
| 460 |
<div class="example">
|
| 461 |
<p><strong>Example:</strong> "A Perfume Bottle nestled on a crystalline cliff of glistening snow, overlooking a serene, moonlit valley."</p>
|
| 462 |
</div>
|
| 463 |
</li>
|
| 464 |
-
<li>
|
| 465 |
-
<span class="emoji">💡</span>
|
| 466 |
-
<strong>Step 2: Describe the Foreground</strong>
|
| 467 |
<p>Next, describe the texture, lighting, and style of the foreground element.</p>
|
| 468 |
<div class="example">
|
| 469 |
<p><strong>Example:</strong> "A transparent glass perfume bottle, vibrant, sunset lighting reflecting off its surface."</p>
|
| 470 |
</div>
|
| 471 |
</li>
|
| 472 |
-
<li>
|
| 473 |
-
<span class="emoji">🎚️</span>
|
| 474 |
-
<strong>Step 3: Adjust the Intensity</strong>
|
| 475 |
<p>Decide how much change you want to apply to the image. Adjust the intensity to balance between keeping consistency and introducing new elements.</p>
|
| 476 |
</li>
|
| 477 |
</ul>
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
gr.HTML("""
|
| 481 |
-
<center><h2><a href="https://api-dashboard.fotographer.ai/login.html">🔗 Check out our API!</a></h2></center>""")
|
| 482 |
|
|
|
|
|
|
|
| 483 |
with gr.Row():
|
| 484 |
gr.Markdown("### F.ai Fuzer: Real Composite Photography in 2 minutes!")
|
|
|
|
| 485 |
with gr.Row():
|
| 486 |
fore = gr.Image(image_mode='RGBA', type="pil", label="Foreground Image", height=400, width=400)
|
| 487 |
with gr.Column():
|
| 488 |
-
result_gallery = gr.Image(label='Output')
|
|
|
|
| 489 |
with gr.Row():
|
| 490 |
prompt = gr.Textbox(label="Prompt")
|
| 491 |
with gr.Column():
|
| 492 |
refprompt = gr.Textbox(label="Refiner Prompt")
|
|
|
|
| 493 |
with gr.Row():
|
| 494 |
-
mode = gr.Radio(choices=[e.value for e in Stage],
|
| 495 |
-
value=Stage.FULL.value,
|
| 496 |
-
label="Generation Mode", type='value')
|
| 497 |
mode.change(fn=update_value, inputs=mode, outputs=mode)
|
| 498 |
-
|
| 499 |
-
with gr.Column():
|
| 500 |
-
gr.HTML('''
|
| 501 |
-
<div class="container">
|
| 502 |
-
<h1>🚀 For more freedom of usage, check out our API</h1>
|
| 503 |
-
<p>👤 You can test with free credits:</p>
|
| 504 |
-
<h2><a href="https://api-dashboard.fotographer.ai/login.html">🔗 API Dashboard</a></h2>
|
| 505 |
-
</div>
|
| 506 |
-
''')
|
| 507 |
-
|
| 508 |
with gr.Row():
|
| 509 |
intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.5)
|
| 510 |
intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
|
|
@@ -513,7 +509,6 @@ with block:
|
|
| 513 |
generate_button = gr.Button(value="Generate", elem_classes="custom-button")
|
| 514 |
|
| 515 |
gr.HTML('''
|
| 516 |
-
|
| 517 |
<div class="container">
|
| 518 |
<h2>Features:</h2>
|
| 519 |
<ul>
|
|
@@ -522,12 +517,10 @@ with block:
|
|
| 522 |
<li>🎨 <strong>Custom Background Control:</strong> Choose or generate backgrounds that perfectly match your creative vision.</li>
|
| 523 |
<li>⚙️ <strong>Easy Integration:</strong> Integrates smoothly with your existing workflow and tools.</li>
|
| 524 |
</ul>
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
<center><h2><a href="https://fotographer.ai/">🔗 Check Out our other Projects Here!</a></h2></center>""")
|
| 530 |
-
|
| 531 |
with gr.Row():
|
| 532 |
dummy_image_for_outputs = gr.Image(visible=False, label='Result', height=400, width=400)
|
| 533 |
gr.Examples(
|
|
@@ -536,23 +529,9 @@ with block:
|
|
| 536 |
inputs=[
|
| 537 |
fore, prompt, intensity, mode, refprompt, isrmbg, dummy_image_for_outputs
|
| 538 |
]
|
| 539 |
-
|
| 540 |
)
|
| 541 |
-
'''
|
| 542 |
-
with gr.Column():
|
| 543 |
-
dummy_image_for_outputs = gr.Image(visible=False, label='Result')
|
| 544 |
-
gr.Examples(
|
| 545 |
-
examples=outputs_list,
|
| 546 |
-
inputs=[dummy_image_for_outputs],
|
| 547 |
-
|
| 548 |
-
)
|
| 549 |
-
'''
|
| 550 |
-
|
| 551 |
-
|
| 552 |
|
| 553 |
ins = [fore, prompt, intensity, mode, refprompt, isrmbg]
|
| 554 |
generate_button.click(fn=process_generate, inputs=ins, outputs=[result_gallery])
|
| 555 |
|
| 556 |
-
|
| 557 |
-
|
| 558 |
block.launch()
|
|
|
|
| 281 |
SECOND_STAGE = "refiner"
|
| 282 |
FULL = "full"
|
| 283 |
|
| 284 |
+
# CSS for styling
|
| 285 |
+
css = """
|
| 286 |
+
/* General Styles */
|
| 287 |
+
body {
|
| 288 |
+
font-family: Arial, sans-serif;
|
| 289 |
+
background-color: #f4f4f9;
|
| 290 |
+
margin: 0;
|
| 291 |
+
padding: 0;
|
| 292 |
+
display: flex;
|
| 293 |
+
flex-direction: column;
|
| 294 |
+
align-items: center;
|
| 295 |
+
color: #333;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
.custom-button {
|
| 299 |
+
background: linear-gradient(271.15deg, #00C7E2 0.27%, #00CC6A 48.52%, #70FF00 102.07%);
|
| 300 |
+
font-size: 4vw; /* Responsive font size */
|
| 301 |
+
color: white;
|
| 302 |
+
padding: 2vw 4vw; /* Responsive padding */
|
| 303 |
+
border: none;
|
| 304 |
+
border-radius: 5px;
|
| 305 |
+
cursor: pointer;
|
| 306 |
+
transition: opacity 0.3s ease;
|
| 307 |
+
width: 100%;
|
| 308 |
+
max-width: 250px;
|
| 309 |
+
}
|
| 310 |
+
|
| 311 |
+
.custom-button:hover {
|
| 312 |
+
opacity: 0.8;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
.custom-title {
|
| 316 |
+
font-size: 6vw; /* Responsive font size */
|
| 317 |
+
background: linear-gradient(271.15deg, #00C7E2 0.27%, #12C06D 102.07%);
|
| 318 |
+
-webkit-background-clip: text;
|
| 319 |
+
-webkit-text-fill-color: transparent;
|
| 320 |
+
font-weight: bold;
|
| 321 |
text-align: center;
|
| 322 |
+
margin-bottom: 2vw;
|
| 323 |
+
width: 100%;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
.container, .example {
|
| 327 |
+
width: 100%;
|
| 328 |
+
padding: 0 1rem;
|
| 329 |
+
box-sizing: border-box;
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
h1, h2 {
|
| 333 |
+
color: #222222;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
a {
|
| 337 |
+
color: #4a90e2;
|
| 338 |
+
text-decoration: none;
|
| 339 |
+
font-weight: bold;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
a:hover {
|
| 343 |
+
text-decoration: underline;
|
| 344 |
+
}
|
| 345 |
+
|
| 346 |
+
.emoji {
|
| 347 |
+
font-size: 1.5em;
|
| 348 |
}
|
| 349 |
|
| 350 |
#share-btn-container {
|
|
|
|
| 354 |
justify-content: center;
|
| 355 |
align-items: center;
|
| 356 |
border-radius: 9999px !important;
|
| 357 |
+
max-width: 100%;
|
| 358 |
+
margin: 1rem auto;
|
| 359 |
}
|
| 360 |
|
| 361 |
#share-btn-container > div {
|
|
|
|
| 403 |
background: #1565c0;
|
| 404 |
}
|
| 405 |
|
| 406 |
+
img, canvas {
|
| 407 |
+
max-width: 100%;
|
| 408 |
+
height: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
}
|
| 410 |
|
| 411 |
+
/* Responsive Adjustments */
|
| 412 |
@media (max-width: 768px) {
|
| 413 |
.custom-button {
|
| 414 |
+
font-size: 5vw;
|
| 415 |
+
padding: 2vw 4vw;
|
| 416 |
}
|
| 417 |
|
| 418 |
.custom-title {
|
| 419 |
+
font-size: 8vw;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
}
|
| 421 |
|
| 422 |
+
h1, h2 {
|
| 423 |
+
font-size: 6vw;
|
| 424 |
}
|
| 425 |
}
|
| 426 |
|
| 427 |
@media (max-width: 480px) {
|
| 428 |
.custom-button {
|
| 429 |
+
font-size: 6vw;
|
| 430 |
+
padding: 3vw 6vw;
|
| 431 |
}
|
| 432 |
|
| 433 |
.custom-title {
|
| 434 |
+
font-size: 10vw;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
}
|
| 436 |
|
| 437 |
+
h1, h2 {
|
| 438 |
+
font-size: 6vw;
|
| 439 |
}
|
| 440 |
|
| 441 |
#share-btn-container {
|
|
|
|
| 443 |
padding: 0.5rem;
|
| 444 |
}
|
| 445 |
}
|
| 446 |
+
"""
|
| 447 |
+
|
| 448 |
+
# Function to process image generation
|
| 449 |
+
def process_generate(fore, prompt, intensity, mode, refprompt, isrmbg):
|
| 450 |
+
# Your function logic here
|
| 451 |
+
return fore
|
| 452 |
+
|
| 453 |
+
# Define the layout using Gradio
|
| 454 |
block = gr.Blocks(css=css, title="## F.ai Fuzer").queue()
|
| 455 |
with block:
|
| 456 |
+
gr.HTML('<meta name="viewport" content="width=device-width, initial-scale=1.0">')
|
| 457 |
+
|
| 458 |
gr.HTML('''
|
|
|
|
| 459 |
<div class="container">
|
| 460 |
<center><h1 class="custom-title">Fotographer.ai Fuzer v0.1: Transcending image Generation Control🎨</h1></center>
|
| 461 |
+
<h2>Control Your Creativity with Unmatched Precision:</h2>
|
| 462 |
<p>Fotographer.ai Fuzer v0.1 empowers you to seamlessly blend foreground elements with any background, while maintaining the shape and style consistency of the foreground. This tool transcends traditional image generation methods by giving you unprecedented control over the final output.</p>
|
|
|
|
| 463 |
<h2>Step-by-Step Instructions</h2>
|
| 464 |
<p>Follow these instructions to control the generation of backgrounds while keeping the foreground's shape and style consistent:</p>
|
| 465 |
<ul>
|
| 466 |
+
<li><span class="emoji">📝</span> <strong>Step 1: Describe the Background</strong>
|
|
|
|
|
|
|
| 467 |
<p>Start by providing a detailed description of the background you want to create.</p>
|
| 468 |
<div class="example">
|
| 469 |
<p><strong>Example:</strong> "A Perfume Bottle nestled on a crystalline cliff of glistening snow, overlooking a serene, moonlit valley."</p>
|
| 470 |
</div>
|
| 471 |
</li>
|
| 472 |
+
<li><span class="emoji">💡</span> <strong>Step 2: Describe the Foreground</strong>
|
|
|
|
|
|
|
| 473 |
<p>Next, describe the texture, lighting, and style of the foreground element.</p>
|
| 474 |
<div class="example">
|
| 475 |
<p><strong>Example:</strong> "A transparent glass perfume bottle, vibrant, sunset lighting reflecting off its surface."</p>
|
| 476 |
</div>
|
| 477 |
</li>
|
| 478 |
+
<li><span class="emoji">🎚️</span> <strong>Step 3: Adjust the Intensity</strong>
|
|
|
|
|
|
|
| 479 |
<p>Decide how much change you want to apply to the image. Adjust the intensity to balance between keeping consistency and introducing new elements.</p>
|
| 480 |
</li>
|
| 481 |
</ul>
|
| 482 |
+
</div>
|
| 483 |
+
''')
|
|
|
|
|
|
|
| 484 |
|
| 485 |
+
gr.HTML('<center><h2><a href="https://api-dashboard.fotographer.ai/login.html">🔗 Check out our API!</a></h2></center>')
|
| 486 |
+
|
| 487 |
with gr.Row():
|
| 488 |
gr.Markdown("### F.ai Fuzer: Real Composite Photography in 2 minutes!")
|
| 489 |
+
|
| 490 |
with gr.Row():
|
| 491 |
fore = gr.Image(image_mode='RGBA', type="pil", label="Foreground Image", height=400, width=400)
|
| 492 |
with gr.Column():
|
| 493 |
+
result_gallery = gr.Image(label='Output')
|
| 494 |
+
|
| 495 |
with gr.Row():
|
| 496 |
prompt = gr.Textbox(label="Prompt")
|
| 497 |
with gr.Column():
|
| 498 |
refprompt = gr.Textbox(label="Refiner Prompt")
|
| 499 |
+
|
| 500 |
with gr.Row():
|
| 501 |
+
mode = gr.Radio(choices=[e.value for e in Stage], value=Stage.FULL.value, label="Generation Mode", type='value')
|
|
|
|
|
|
|
| 502 |
mode.change(fn=update_value, inputs=mode, outputs=mode)
|
| 503 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 504 |
with gr.Row():
|
| 505 |
intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.5)
|
| 506 |
intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
|
|
|
|
| 509 |
generate_button = gr.Button(value="Generate", elem_classes="custom-button")
|
| 510 |
|
| 511 |
gr.HTML('''
|
|
|
|
| 512 |
<div class="container">
|
| 513 |
<h2>Features:</h2>
|
| 514 |
<ul>
|
|
|
|
| 517 |
<li>🎨 <strong>Custom Background Control:</strong> Choose or generate backgrounds that perfectly match your creative vision.</li>
|
| 518 |
<li>⚙️ <strong>Easy Integration:</strong> Integrates smoothly with your existing workflow and tools.</li>
|
| 519 |
</ul>
|
| 520 |
+
''')
|
| 521 |
+
|
| 522 |
+
gr.HTML('<center><h2><a href="https://fotographer.ai/">🔗 Check Out our other Projects Here!</a></h2></center>')
|
| 523 |
+
|
|
|
|
|
|
|
| 524 |
with gr.Row():
|
| 525 |
dummy_image_for_outputs = gr.Image(visible=False, label='Result', height=400, width=400)
|
| 526 |
gr.Examples(
|
|
|
|
| 529 |
inputs=[
|
| 530 |
fore, prompt, intensity, mode, refprompt, isrmbg, dummy_image_for_outputs
|
| 531 |
]
|
|
|
|
| 532 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
|
| 534 |
ins = [fore, prompt, intensity, mode, refprompt, isrmbg]
|
| 535 |
generate_button.click(fn=process_generate, inputs=ins, outputs=[result_gallery])
|
| 536 |
|
|
|
|
|
|
|
| 537 |
block.launch()
|