Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -77,11 +77,10 @@ class timer:
|
|
| 77 |
if not path.exists(cache_path):
|
| 78 |
os.makedirs(cache_path, exist_ok=True)
|
| 79 |
|
| 80 |
-
# ์ธ์ฆ๋ ๋ชจ๋ธ ๋ก๋
|
| 81 |
pipe = FluxPipeline.from_pretrained(
|
| 82 |
"black-forest-labs/FLUX.1-dev",
|
| 83 |
torch_dtype=torch.bfloat16,
|
| 84 |
-
use_auth_token=HF_TOKEN
|
| 85 |
)
|
| 86 |
|
| 87 |
# Hyper-SD LoRA ๋ก๋
|
|
@@ -134,7 +133,7 @@ def process_and_save_image(height=1024, width=1024, steps=8, scales=3.5, prompt=
|
|
| 134 |
global pipe
|
| 135 |
|
| 136 |
if seed is None:
|
| 137 |
-
seed =
|
| 138 |
|
| 139 |
# ํ๊ธ ๊ฐ์ง ๋ฐ ๋ฒ์ญ
|
| 140 |
def contains_korean(text):
|
|
@@ -201,10 +200,6 @@ with gr.Blocks(
|
|
| 201 |
padding: 20px;
|
| 202 |
background: #f5f5f5;
|
| 203 |
border-radius: 15px;
|
| 204 |
-
/*
|
| 205 |
-
์๋์ฒ๋ผ width:100% & margin:0 auto๋ฅผ ์ฃผ๋ฉด
|
| 206 |
-
ํ๋ฉด ์ ์ฒด๋ฅผ ๋๊ฒ ์ฌ์ฉํ๋ฉด์ ์ค์ ์ ๋ ฌ๋จ
|
| 207 |
-
*/
|
| 208 |
width: 100%;
|
| 209 |
margin: 0 auto;
|
| 210 |
}
|
|
@@ -219,8 +214,8 @@ with gr.Blocks(
|
|
| 219 |
gr.HTML(
|
| 220 |
"""
|
| 221 |
<div style="text-align: center; max-width: 800px; margin: 0 auto; padding: 20px;">
|
| 222 |
-
<h1 style="font-size: 2.5rem; color: #2196F3;">3D Style Image Generator
|
| 223 |
-
<p style="font-size: 1.2rem; color: #666;">Create amazing 3D-style images with AI
|
| 224 |
</div>
|
| 225 |
"""
|
| 226 |
)
|
|
@@ -287,11 +282,10 @@ with gr.Blocks(
|
|
| 287 |
value="3d.webp"
|
| 288 |
)
|
| 289 |
|
| 290 |
-
#
|
| 291 |
-
with gr.
|
| 292 |
gr.HTML("<h2 class='gallery-title'>Gallery</h2>")
|
| 293 |
|
| 294 |
-
# grid-template-columns๋ฅผ repeat(4, 1fr)๋ก ์ง์ ํ์ฌ ํ ์ค์ 4๊ฐ์ฉ ํ์
|
| 295 |
gallery_html = """
|
| 296 |
<div style='
|
| 297 |
display: grid;
|
|
@@ -302,14 +296,11 @@ with gr.Blocks(
|
|
| 302 |
"""
|
| 303 |
|
| 304 |
for img_file, prompt_text in SAMPLE_IMAGES.items():
|
| 305 |
-
img_path = os.path.abspath(img_file)
|
| 306 |
if os.path.exists(img_path):
|
| 307 |
try:
|
| 308 |
-
# Base64๋ก ์ด๋ฏธ์ง ์ธ์ฝ๋ฉ
|
| 309 |
with open(img_path, "rb") as img:
|
| 310 |
img_data = base64.b64encode(img.read()).decode()
|
| 311 |
-
|
| 312 |
-
# MIMEํ์
(webp)
|
| 313 |
gallery_html += f"""
|
| 314 |
<div style='
|
| 315 |
border: 1px solid #ddd;
|
|
@@ -340,7 +331,7 @@ with gr.Blocks(
|
|
| 340 |
# ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
| 341 |
generate_btn.click(
|
| 342 |
fn=process_and_save_image,
|
| 343 |
-
inputs=[height, width, steps, scales, prompt, seed],
|
| 344 |
outputs=output
|
| 345 |
)
|
| 346 |
|
|
|
|
| 77 |
if not path.exists(cache_path):
|
| 78 |
os.makedirs(cache_path, exist_ok=True)
|
| 79 |
|
|
|
|
| 80 |
pipe = FluxPipeline.from_pretrained(
|
| 81 |
"black-forest-labs/FLUX.1-dev",
|
| 82 |
torch_dtype=torch.bfloat16,
|
| 83 |
+
use_auth_token=HF_TOKEN # ๊ฒฝ๊ณ ๋ฉ์์ง๊ฐ ๋จ์ง๋ง ๋ฌด์ ๊ฐ๋ฅ
|
| 84 |
)
|
| 85 |
|
| 86 |
# Hyper-SD LoRA ๋ก๋
|
|
|
|
| 133 |
global pipe
|
| 134 |
|
| 135 |
if seed is None:
|
| 136 |
+
seed = get_random_seed()
|
| 137 |
|
| 138 |
# ํ๊ธ ๊ฐ์ง ๋ฐ ๋ฒ์ญ
|
| 139 |
def contains_korean(text):
|
|
|
|
| 200 |
padding: 20px;
|
| 201 |
background: #f5f5f5;
|
| 202 |
border-radius: 15px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
width: 100%;
|
| 204 |
margin: 0 auto;
|
| 205 |
}
|
|
|
|
| 214 |
gr.HTML(
|
| 215 |
"""
|
| 216 |
<div style="text-align: center; max-width: 800px; margin: 0 auto; padding: 20px;">
|
| 217 |
+
<h1 style="font-size: 2.5rem; color: #2196F3;">3D Style Image Generator</h1>
|
| 218 |
+
<p style="font-size: 1.2rem; color: #666;">Create amazing 3D-style images with AI</p>
|
| 219 |
</div>
|
| 220 |
"""
|
| 221 |
)
|
|
|
|
| 282 |
value="3d.webp"
|
| 283 |
)
|
| 284 |
|
| 285 |
+
# gallery-container ๋ถ๋ถ์ Group์ผ๋ก ๊ฐ์ธ ํ๋ฉด ์ ์ฒด์ ํ์ฅ
|
| 286 |
+
with gr.Group(elem_classes="gallery-container"):
|
| 287 |
gr.HTML("<h2 class='gallery-title'>Gallery</h2>")
|
| 288 |
|
|
|
|
| 289 |
gallery_html = """
|
| 290 |
<div style='
|
| 291 |
display: grid;
|
|
|
|
| 296 |
"""
|
| 297 |
|
| 298 |
for img_file, prompt_text in SAMPLE_IMAGES.items():
|
| 299 |
+
img_path = os.path.abspath(img_file)
|
| 300 |
if os.path.exists(img_path):
|
| 301 |
try:
|
|
|
|
| 302 |
with open(img_path, "rb") as img:
|
| 303 |
img_data = base64.b64encode(img.read()).decode()
|
|
|
|
|
|
|
| 304 |
gallery_html += f"""
|
| 305 |
<div style='
|
| 306 |
border: 1px solid #ddd;
|
|
|
|
| 331 |
# ์ด๋ฒคํธ ํธ๋ค๋ฌ
|
| 332 |
generate_btn.click(
|
| 333 |
fn=process_and_save_image,
|
| 334 |
+
inputs=[height, width, steps, scales, prompt, seed],
|
| 335 |
outputs=output
|
| 336 |
)
|
| 337 |
|