Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -185,7 +185,7 @@ def calculate_dimensions(aspect_ratio: str, base_size: int = 512) -> tuple[int,
|
|
| 185 |
return base_size * 4 // 3, base_size
|
| 186 |
return base_size, base_size
|
| 187 |
|
| 188 |
-
@spaces.GPU(duration=40)
|
| 189 |
def generate_background(prompt: str, aspect_ratio: str) -> Image.Image:
|
| 190 |
try:
|
| 191 |
width, height = calculate_dimensions(aspect_ratio)
|
|
@@ -206,8 +206,8 @@ def generate_background(prompt: str, aspect_ratio: str) -> Image.Image:
|
|
| 206 |
width=width,
|
| 207 |
height=height,
|
| 208 |
num_inference_steps=8,
|
| 209 |
-
guidance_scale=4.0
|
| 210 |
-
max_length
|
| 211 |
).images[0]
|
| 212 |
except Exception as e:
|
| 213 |
print(f"Pipeline error: {str(e)}")
|
|
@@ -627,64 +627,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
| 627 |
queue=True
|
| 628 |
)
|
| 629 |
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
# ์์ ํ
์ด๋ธ HTML ์์
|
| 633 |
-
gr.HTML("""
|
| 634 |
-
<div style="margin-top: 2em; padding: 1em;">
|
| 635 |
-
<h2 style="text-align: center; color: #2196F3; margin-bottom: 1em;">Examples</h2>
|
| 636 |
-
<div class="examples-container" style="overflow-x: auto;">
|
| 637 |
-
<table style="width: 100%; border-collapse: collapse; margin: auto; background: white; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
|
| 638 |
-
<thead>
|
| 639 |
-
<tr style="background: #f7f7f7;">
|
| 640 |
-
<th style="padding: 1em; border: 1px solid #ddd; min-width: 120px;">Step</th>
|
| 641 |
-
<th style="padding: 1em; border: 1px solid #ddd; min-width: 200px;">Example 1</th>
|
| 642 |
-
<th style="padding: 1em; border: 1px solid #ddd; min-width: 200px;">Example 2</th>
|
| 643 |
-
</tr>
|
| 644 |
-
</thead>
|
| 645 |
-
<tbody>
|
| 646 |
-
<tr>
|
| 647 |
-
<td style="padding: 1em; border: 1px solid #ddd;">Upload Image</td>
|
| 648 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">
|
| 649 |
-
<img src="https://raw.githubusercontent.com/your-username/your-repo/main/examples/example1_input.jpg" style="max-width: 150px; height: auto;" alt="Example 1 Input">
|
| 650 |
-
</td>
|
| 651 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">
|
| 652 |
-
<img src="https://raw.githubusercontent.com/your-username/your-repo/main/examples/example2_input.jpg" style="max-width: 150px; height: auto;" alt="Example 2 Input">
|
| 653 |
-
</td>
|
| 654 |
-
</tr>
|
| 655 |
-
<tr>
|
| 656 |
-
<td style="padding: 1em; border: 1px solid #ddd;">Object Extract</td>
|
| 657 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">text</td>
|
| 658 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">sunglasses</td>
|
| 659 |
-
</tr>
|
| 660 |
-
<tr>
|
| 661 |
-
<td style="padding: 1em; border: 1px solid #ddd;">Background Prompt</td>
|
| 662 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">The Alps in Spring with Blossoming Flowers</td>
|
| 663 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">ํ์์ด beach</td>
|
| 664 |
-
</tr>
|
| 665 |
-
<tr>
|
| 666 |
-
<td style="padding: 1em; border: 1px solid #ddd;">Object Cutoff Image</td>
|
| 667 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">
|
| 668 |
-
<img src="https://raw.githubusercontent.com/your-username/your-repo/main/examples/example1_cutoff.jpg" style="max-width: 150px; height: auto;" alt="Example 1 Cutoff">
|
| 669 |
-
</td>
|
| 670 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">
|
| 671 |
-
<img src="https://raw.githubusercontent.com/your-username/your-repo/main/examples/example2_cutoff.jpg" style="max-width: 150px; height: auto;" alt="Example 2 Cutoff">
|
| 672 |
-
</td>
|
| 673 |
-
</tr>
|
| 674 |
-
<tr>
|
| 675 |
-
<td style="padding: 1em; border: 1px solid #ddd;">Result Image</td>
|
| 676 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">
|
| 677 |
-
<img src="https://raw.githubusercontent.com/your-username/your-repo/main/examples/example1_result.jpg" style="max-width: 150px; height: auto;" alt="Example 1 Result">
|
| 678 |
-
</td>
|
| 679 |
-
<td style="padding: 1em; border: 1px solid #ddd; text-align: center;">
|
| 680 |
-
<img src="https://raw.githubusercontent.com/your-username/your-repo/main/examples/example2_result.jpg" style="max-width: 150px; height: auto;" alt="Example 2 Result">
|
| 681 |
-
</td>
|
| 682 |
-
</tr>
|
| 683 |
-
</tbody>
|
| 684 |
-
</table>
|
| 685 |
-
</div>
|
| 686 |
-
</div>
|
| 687 |
-
""")
|
| 688 |
demo.queue(max_size=10) # ํ ํฌ๊ธฐ ์ ํ
|
| 689 |
demo.launch(
|
| 690 |
server_name="0.0.0.0",
|
|
|
|
| 185 |
return base_size * 4 // 3, base_size
|
| 186 |
return base_size, base_size
|
| 187 |
|
| 188 |
+
@spaces.GPU(duration=40)
|
| 189 |
def generate_background(prompt: str, aspect_ratio: str) -> Image.Image:
|
| 190 |
try:
|
| 191 |
width, height = calculate_dimensions(aspect_ratio)
|
|
|
|
| 206 |
width=width,
|
| 207 |
height=height,
|
| 208 |
num_inference_steps=8,
|
| 209 |
+
guidance_scale=4.0
|
| 210 |
+
# max_length ํ๋ผ๋ฏธํฐ ์ ๊ฑฐ
|
| 211 |
).images[0]
|
| 212 |
except Exception as e:
|
| 213 |
print(f"Pipeline error: {str(e)}")
|
|
|
|
| 627 |
queue=True
|
| 628 |
)
|
| 629 |
|
| 630 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
demo.queue(max_size=10) # ํ ํฌ๊ธฐ ์ ํ
|
| 632 |
demo.launch(
|
| 633 |
server_name="0.0.0.0",
|