Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
#version 2
|
| 2 |
import os
|
| 3 |
import math
|
| 4 |
import gradio as gr
|
|
@@ -32,7 +32,7 @@ prompt_list = ["A Perfume Bottle, resting on a wooden table, surrounded by laven
|
|
| 32 |
example_list = [
|
| 33 |
[
|
| 34 |
"examples/in5.png",
|
| 35 |
-
"A Perfume bottle, perched delicately on a rock by the ocean, with a breathtaking sunset casting a golden glow over the waves",
|
| 36 |
3.5,
|
| 37 |
"full",
|
| 38 |
"(( A transparent perfume Bottle with a black cap )), and a yellow liquide, sunset, transparent",
|
|
@@ -136,7 +136,6 @@ def create_square_image(image):
|
|
| 136 |
"""
|
| 137 |
Create a new square image with the side length equal to the largest dimension
|
| 138 |
of the original image and paste the original image at the center on a transparent canvas.
|
| 139 |
-
|
| 140 |
:param image: A PIL image.
|
| 141 |
:return: A new square PIL image.
|
| 142 |
"""
|
|
@@ -196,7 +195,6 @@ def process(data, api, api_key):
|
|
| 196 |
def resize_to_fit(max_size, original_size):
|
| 197 |
"""
|
| 198 |
Calculate the new size for an image to fit within max_size while maintaining the aspect ratio.
|
| 199 |
-
|
| 200 |
:param max_size: Maximum allowed size as a tuple (width, height).
|
| 201 |
:param original_size: Original size of the image as a tuple (width, height).
|
| 202 |
:return: New size as a tuple (new_width, new_height) that fits within max_size while maintaining the aspect ratio.
|
|
@@ -297,7 +295,6 @@ class Stage(Enum):
|
|
| 297 |
css="""#disp_image {
|
| 298 |
text-align: center;
|
| 299 |
}
|
| 300 |
-
|
| 301 |
#share-btn-container {
|
| 302 |
padding-left: 0.5rem !important;
|
| 303 |
padding-right: 0.5rem !important;
|
|
@@ -308,17 +305,14 @@ css="""#disp_image {
|
|
| 308 |
max-width: 13rem;
|
| 309 |
margin-left: auto;
|
| 310 |
}
|
| 311 |
-
|
| 312 |
#share-btn-container > div {
|
| 313 |
flex-direction: row;
|
| 314 |
background: black;
|
| 315 |
align-items: center;
|
| 316 |
}
|
| 317 |
-
|
| 318 |
#share-btn-container:hover {
|
| 319 |
background-color: #060606;
|
| 320 |
}
|
| 321 |
-
|
| 322 |
#share-btn {
|
| 323 |
all: initial;
|
| 324 |
color: #ffffff;
|
|
@@ -330,43 +324,32 @@ css="""#disp_image {
|
|
| 330 |
padding-bottom: 0.5rem !important;
|
| 331 |
right: 0;
|
| 332 |
}
|
| 333 |
-
|
| 334 |
#share-btn * {
|
| 335 |
all: unset;
|
| 336 |
}
|
| 337 |
-
|
| 338 |
#share-btn-container div:nth-child(-n+2) {
|
| 339 |
width: auto !important;
|
| 340 |
min-height: 0px !important;
|
| 341 |
}
|
| 342 |
-
|
| 343 |
#share-btn-container .wrap {
|
| 344 |
display: none !important;
|
| 345 |
}
|
| 346 |
-
|
| 347 |
#share-btn-container.hidden {
|
| 348 |
display: none !important;
|
| 349 |
}
|
| 350 |
-
|
| 351 |
#duplicate-button {
|
| 352 |
margin-left: auto;
|
| 353 |
color: #fff;
|
| 354 |
background: #1565c0;
|
| 355 |
}
|
| 356 |
-
|
| 357 |
body {
|
| 358 |
font-family: Arial, sans-serif;
|
| 359 |
background-color: #f4f4f9;
|
| 360 |
margin: 0;
|
| 361 |
padding: 0;
|
| 362 |
-
display: flex;
|
| 363 |
-
flex-direction: column;
|
| 364 |
-
justify-content: center;
|
| 365 |
-
align-items: center;
|
| 366 |
min-height: 100vh;
|
| 367 |
color: #333;
|
| 368 |
}
|
| 369 |
-
|
| 370 |
.custom-button {
|
| 371 |
background: linear-gradient(271.15deg, #00C7E2 0.27%, #00CC6A 48.52%, #70FF00 102.07%);
|
| 372 |
font-size: 30px;
|
|
@@ -377,11 +360,9 @@ body {
|
|
| 377 |
cursor: pointer;
|
| 378 |
transition: opacity 0.3s ease;
|
| 379 |
}
|
| 380 |
-
|
| 381 |
.custom-button:hover {
|
| 382 |
opacity: 0.8;
|
| 383 |
}
|
| 384 |
-
|
| 385 |
.custom-title {
|
| 386 |
font-size: 36px;
|
| 387 |
background: linear-gradient(271.15deg, #00C7E2 0.27%, #12C06D 102.07%);
|
|
@@ -391,62 +372,49 @@ body {
|
|
| 391 |
text-align: center;
|
| 392 |
margin-bottom: 20px;
|
| 393 |
}
|
| 394 |
-
|
| 395 |
h1 {
|
| 396 |
color: #222222;
|
| 397 |
}
|
| 398 |
-
|
| 399 |
a {
|
| 400 |
color: #4a90e2;
|
| 401 |
text-decoration: none;
|
| 402 |
font-weight: bold;
|
| 403 |
}
|
| 404 |
-
|
| 405 |
a:hover {
|
| 406 |
text-decoration: underline;
|
| 407 |
}
|
| 408 |
-
|
| 409 |
.emoji {
|
| 410 |
font-size: 1.5em;
|
| 411 |
}
|
| 412 |
-
|
| 413 |
@media (max-width: 768px) {
|
| 414 |
.custom-button {
|
| 415 |
font-size: 20px;
|
| 416 |
padding: 8px 16px;
|
| 417 |
}
|
| 418 |
-
|
| 419 |
.custom-title {
|
| 420 |
font-size: 28px;
|
| 421 |
}
|
| 422 |
-
|
| 423 |
#disp_image, .container {
|
| 424 |
padding: 0 1rem;
|
| 425 |
}
|
| 426 |
-
|
| 427 |
h1 {
|
| 428 |
font-size: 24px;
|
| 429 |
}
|
| 430 |
}
|
| 431 |
-
|
| 432 |
@media (max-width: 480px) {
|
| 433 |
.custom-button {
|
| 434 |
font-size: 16px;
|
| 435 |
padding: 6px 12px;
|
| 436 |
}
|
| 437 |
-
|
| 438 |
.custom-title {
|
| 439 |
font-size: 22px;
|
| 440 |
}
|
| 441 |
-
|
| 442 |
.container {
|
| 443 |
padding: 0 0.5rem;
|
| 444 |
}
|
| 445 |
-
|
| 446 |
h1 {
|
| 447 |
font-size: 20px;
|
| 448 |
}
|
| 449 |
-
|
| 450 |
#share-btn-container {
|
| 451 |
max-width: 100%;
|
| 452 |
padding: 0.5rem;
|
|
@@ -463,7 +431,6 @@ with block:
|
|
| 463 |
<h2>Welcome to the Updated Version of FAI Fuzer!</h2>
|
| 464 |
<p>This is FAI Fuzer medium v0.3, an updated version of our previously released Fuzer v0.1. In this version, we've introduced several enhancements, including the addition of a new anime model to broaden your creative possibilities.</p>
|
| 465 |
<p>We appreciate the feedback and support from our community and are excited to bring these new features to you.</p>
|
| 466 |
-
|
| 467 |
<p><strong>What's New in v0.3:</strong></p>
|
| 468 |
<ul>
|
| 469 |
<li>🚀 Introduction of an Anime Model: Now you can choose between "realistic" and "anime" styles for your images.</li>
|
|
@@ -508,28 +475,29 @@ with block:
|
|
| 508 |
with gr.Row():
|
| 509 |
gr.Markdown("### F.ai Fuzer: Real Composite Photography in 2 minutes!")
|
| 510 |
with gr.Row():
|
| 511 |
-
fore = gr.Image(image_mode='RGBA', type="pil", label="Foreground Image", height=400, width=400)
|
| 512 |
-
with gr.Column():
|
| 513 |
-
|
| 514 |
with gr.Row():
|
| 515 |
-
prompt = gr.Textbox(label="Prompt")
|
| 516 |
-
with gr.Column():
|
| 517 |
-
|
| 518 |
with gr.Row():
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
|
|
|
| 523 |
|
| 524 |
-
|
| 525 |
-
model_type = gr.Dropdown(choices=["realistic","anime"], label="Model Type", value="realistic") # Adding the Dropdown for model selection
|
| 526 |
|
|
|
|
| 527 |
# Adding Advanced Settings for the number of steps and control strength
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
|
| 532 |
-
with gr.Column():
|
| 533 |
gr.HTML('''
|
| 534 |
<div class="container">
|
| 535 |
<h1>🚀 For more freedom of usage, check out our API</h1>
|
|
@@ -537,7 +505,7 @@ with block:
|
|
| 537 |
<h2><a href="https://fotographer.ai/api/top">🔗 API Dashboard</a></h2>
|
| 538 |
</div>
|
| 539 |
''')
|
| 540 |
-
|
| 541 |
with gr.Row():
|
| 542 |
intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.5)
|
| 543 |
intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
|
|
@@ -562,7 +530,7 @@ with block:
|
|
| 562 |
<center><h2><a href="https://fotographer.ai/">🔗 Check Out our other Projects Here!</a></h2></center>""")
|
| 563 |
|
| 564 |
with gr.Row():
|
| 565 |
-
dummy_image_for_outputs = gr.Image(visible=False, label='Result'
|
| 566 |
gr.Examples(
|
| 567 |
fn=lambda *args: [args[-1]],
|
| 568 |
examples=example_list,
|
|
|
|
| 1 |
+
#version 2.1
|
| 2 |
import os
|
| 3 |
import math
|
| 4 |
import gradio as gr
|
|
|
|
| 32 |
example_list = [
|
| 33 |
[
|
| 34 |
"examples/in5.png",
|
| 35 |
+
"A Perfume bottle, perched delicately on a rock ⁄by the ocean, with a breathtaking sunset casting a golden glow over the waves",
|
| 36 |
3.5,
|
| 37 |
"full",
|
| 38 |
"(( A transparent perfume Bottle with a black cap )), and a yellow liquide, sunset, transparent",
|
|
|
|
| 136 |
"""
|
| 137 |
Create a new square image with the side length equal to the largest dimension
|
| 138 |
of the original image and paste the original image at the center on a transparent canvas.
|
|
|
|
| 139 |
:param image: A PIL image.
|
| 140 |
:return: A new square PIL image.
|
| 141 |
"""
|
|
|
|
| 195 |
def resize_to_fit(max_size, original_size):
|
| 196 |
"""
|
| 197 |
Calculate the new size for an image to fit within max_size while maintaining the aspect ratio.
|
|
|
|
| 198 |
:param max_size: Maximum allowed size as a tuple (width, height).
|
| 199 |
:param original_size: Original size of the image as a tuple (width, height).
|
| 200 |
:return: New size as a tuple (new_width, new_height) that fits within max_size while maintaining the aspect ratio.
|
|
|
|
| 295 |
css="""#disp_image {
|
| 296 |
text-align: center;
|
| 297 |
}
|
|
|
|
| 298 |
#share-btn-container {
|
| 299 |
padding-left: 0.5rem !important;
|
| 300 |
padding-right: 0.5rem !important;
|
|
|
|
| 305 |
max-width: 13rem;
|
| 306 |
margin-left: auto;
|
| 307 |
}
|
|
|
|
| 308 |
#share-btn-container > div {
|
| 309 |
flex-direction: row;
|
| 310 |
background: black;
|
| 311 |
align-items: center;
|
| 312 |
}
|
|
|
|
| 313 |
#share-btn-container:hover {
|
| 314 |
background-color: #060606;
|
| 315 |
}
|
|
|
|
| 316 |
#share-btn {
|
| 317 |
all: initial;
|
| 318 |
color: #ffffff;
|
|
|
|
| 324 |
padding-bottom: 0.5rem !important;
|
| 325 |
right: 0;
|
| 326 |
}
|
|
|
|
| 327 |
#share-btn * {
|
| 328 |
all: unset;
|
| 329 |
}
|
|
|
|
| 330 |
#share-btn-container div:nth-child(-n+2) {
|
| 331 |
width: auto !important;
|
| 332 |
min-height: 0px !important;
|
| 333 |
}
|
|
|
|
| 334 |
#share-btn-container .wrap {
|
| 335 |
display: none !important;
|
| 336 |
}
|
|
|
|
| 337 |
#share-btn-container.hidden {
|
| 338 |
display: none !important;
|
| 339 |
}
|
|
|
|
| 340 |
#duplicate-button {
|
| 341 |
margin-left: auto;
|
| 342 |
color: #fff;
|
| 343 |
background: #1565c0;
|
| 344 |
}
|
|
|
|
| 345 |
body {
|
| 346 |
font-family: Arial, sans-serif;
|
| 347 |
background-color: #f4f4f9;
|
| 348 |
margin: 0;
|
| 349 |
padding: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 350 |
min-height: 100vh;
|
| 351 |
color: #333;
|
| 352 |
}
|
|
|
|
| 353 |
.custom-button {
|
| 354 |
background: linear-gradient(271.15deg, #00C7E2 0.27%, #00CC6A 48.52%, #70FF00 102.07%);
|
| 355 |
font-size: 30px;
|
|
|
|
| 360 |
cursor: pointer;
|
| 361 |
transition: opacity 0.3s ease;
|
| 362 |
}
|
|
|
|
| 363 |
.custom-button:hover {
|
| 364 |
opacity: 0.8;
|
| 365 |
}
|
|
|
|
| 366 |
.custom-title {
|
| 367 |
font-size: 36px;
|
| 368 |
background: linear-gradient(271.15deg, #00C7E2 0.27%, #12C06D 102.07%);
|
|
|
|
| 372 |
text-align: center;
|
| 373 |
margin-bottom: 20px;
|
| 374 |
}
|
|
|
|
| 375 |
h1 {
|
| 376 |
color: #222222;
|
| 377 |
}
|
|
|
|
| 378 |
a {
|
| 379 |
color: #4a90e2;
|
| 380 |
text-decoration: none;
|
| 381 |
font-weight: bold;
|
| 382 |
}
|
|
|
|
| 383 |
a:hover {
|
| 384 |
text-decoration: underline;
|
| 385 |
}
|
|
|
|
| 386 |
.emoji {
|
| 387 |
font-size: 1.5em;
|
| 388 |
}
|
|
|
|
| 389 |
@media (max-width: 768px) {
|
| 390 |
.custom-button {
|
| 391 |
font-size: 20px;
|
| 392 |
padding: 8px 16px;
|
| 393 |
}
|
|
|
|
| 394 |
.custom-title {
|
| 395 |
font-size: 28px;
|
| 396 |
}
|
|
|
|
| 397 |
#disp_image, .container {
|
| 398 |
padding: 0 1rem;
|
| 399 |
}
|
|
|
|
| 400 |
h1 {
|
| 401 |
font-size: 24px;
|
| 402 |
}
|
| 403 |
}
|
|
|
|
| 404 |
@media (max-width: 480px) {
|
| 405 |
.custom-button {
|
| 406 |
font-size: 16px;
|
| 407 |
padding: 6px 12px;
|
| 408 |
}
|
|
|
|
| 409 |
.custom-title {
|
| 410 |
font-size: 22px;
|
| 411 |
}
|
|
|
|
| 412 |
.container {
|
| 413 |
padding: 0 0.5rem;
|
| 414 |
}
|
|
|
|
| 415 |
h1 {
|
| 416 |
font-size: 20px;
|
| 417 |
}
|
|
|
|
| 418 |
#share-btn-container {
|
| 419 |
max-width: 100%;
|
| 420 |
padding: 0.5rem;
|
|
|
|
| 431 |
<h2>Welcome to the Updated Version of FAI Fuzer!</h2>
|
| 432 |
<p>This is FAI Fuzer medium v0.3, an updated version of our previously released Fuzer v0.1. In this version, we've introduced several enhancements, including the addition of a new anime model to broaden your creative possibilities.</p>
|
| 433 |
<p>We appreciate the feedback and support from our community and are excited to bring these new features to you.</p>
|
|
|
|
| 434 |
<p><strong>What's New in v0.3:</strong></p>
|
| 435 |
<ul>
|
| 436 |
<li>🚀 Introduction of an Anime Model: Now you can choose between "realistic" and "anime" styles for your images.</li>
|
|
|
|
| 475 |
with gr.Row():
|
| 476 |
gr.Markdown("### F.ai Fuzer: Real Composite Photography in 2 minutes!")
|
| 477 |
with gr.Row():
|
| 478 |
+
fore = gr.Image(image_mode='RGBA', type="pil", label="Foreground Image", height=400, width=400, min_width=400)
|
| 479 |
+
# with gr.Column():
|
| 480 |
+
result_gallery = gr.Image(label='Output', min_width=400) #gr.Gallery(height=400, object_fit='contain', label='Outputs')
|
| 481 |
with gr.Row():
|
| 482 |
+
prompt = gr.Textbox(label="Prompt", min_width=400)
|
| 483 |
+
# with gr.Column():
|
| 484 |
+
refprompt = gr.Textbox(label="Refiner Prompt", min_width=400)
|
| 485 |
with gr.Row():
|
| 486 |
+
with gr.Column(min_width=400):
|
| 487 |
+
mode = gr.Radio(choices=[e.value for e in Stage],
|
| 488 |
+
value=Stage.FULL.value,
|
| 489 |
+
label="Generation Mode", type='value', min_width=400)
|
| 490 |
+
mode.change(fn=update_value, inputs=mode, outputs=mode)
|
| 491 |
|
| 492 |
+
model_type = gr.Dropdown(choices=["realistic","anime"], label="Model Type", value="realistic", min_width=400) # Adding the Dropdown for model selection
|
|
|
|
| 493 |
|
| 494 |
+
with gr.Column(min_width=400):
|
| 495 |
# Adding Advanced Settings for the number of steps and control strength
|
| 496 |
+
with gr.Accordion("Advanced Settings", open=True, ):
|
| 497 |
+
steps = gr.Slider(label="Number of Steps", minimum=10, maximum=100, value=30, step=1)
|
| 498 |
+
control_strength = gr.Slider(label="Control Strength", minimum=0.1, maximum=1.0, value=0.5, step=0.1)
|
| 499 |
|
| 500 |
+
with gr.Column(min_width=400):
|
| 501 |
gr.HTML('''
|
| 502 |
<div class="container">
|
| 503 |
<h1>🚀 For more freedom of usage, check out our API</h1>
|
|
|
|
| 505 |
<h2><a href="https://fotographer.ai/api/top">🔗 API Dashboard</a></h2>
|
| 506 |
</div>
|
| 507 |
''')
|
| 508 |
+
|
| 509 |
with gr.Row():
|
| 510 |
intensity = gr.Slider(label="Refiner Strength", minimum=1.0, maximum=7.0, value=3.0, step=0.5)
|
| 511 |
intensity.change(fn=update_value, inputs=intensity, outputs=intensity)
|
|
|
|
| 530 |
<center><h2><a href="https://fotographer.ai/">🔗 Check Out our other Projects Here!</a></h2></center>""")
|
| 531 |
|
| 532 |
with gr.Row():
|
| 533 |
+
dummy_image_for_outputs = gr.Image(visible=False, label='Result')
|
| 534 |
gr.Examples(
|
| 535 |
fn=lambda *args: [args[-1]],
|
| 536 |
examples=example_list,
|