Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import torch
|
|
4 |
from einops import rearrange, repeat
|
5 |
from PIL import Image
|
6 |
import numpy as np
|
|
|
7 |
|
8 |
from flux.sampling import denoise, get_noise, get_schedule, prepare, rf_denoise, rf_inversion, unpack
|
9 |
from flux.util import (
|
@@ -71,6 +72,8 @@ except Exception as e:
|
|
71 |
model_initialized = False
|
72 |
|
73 |
|
|
|
|
|
74 |
@torch.inference_mode()
|
75 |
def generate_image(
|
76 |
prompt: str,
|
@@ -247,7 +250,7 @@ def generate_image(
|
|
247 |
|
248 |
|
249 |
def create_demo():
|
250 |
-
with gr.Blocks(
|
251 |
gr.Markdown("# PuLID: ์ธ๋ฌผ ์ด๋ฏธ์ง ๋ณํ ๋๊ตฌ")
|
252 |
|
253 |
if not model_initialized:
|
@@ -278,7 +281,28 @@ def create_demo():
|
|
278 |
seed_output = gr.Textbox(label="๊ฒฐ๊ณผ/์ค๋ฅ ๋ฉ์์ง")
|
279 |
gr.Markdown(_CITE_)
|
280 |
|
281 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
generate_btn.click(
|
283 |
fn=generate_image,
|
284 |
inputs=[
|
@@ -300,5 +324,7 @@ if __name__ == "__main__":
|
|
300 |
parser.add_argument("--port", type=int, default=8080)
|
301 |
args = parser.parse_args()
|
302 |
|
|
|
|
|
303 |
demo = create_demo()
|
304 |
-
demo.launch(
|
|
|
4 |
from einops import rearrange, repeat
|
5 |
from PIL import Image
|
6 |
import numpy as np
|
7 |
+
import spaces # Hugging Face Spaces ์ํฌํธ ์ถ๊ฐ
|
8 |
|
9 |
from flux.sampling import denoise, get_noise, get_schedule, prepare, rf_denoise, rf_inversion, unpack
|
10 |
from flux.util import (
|
|
|
72 |
model_initialized = False
|
73 |
|
74 |
|
75 |
+
# Spaces GPU ๋ฐ์ฝ๋ ์ดํฐ ์ถ๊ฐ (120์ด GPU ์ฌ์ฉ)
|
76 |
+
@spaces.GPU(duration=120)
|
77 |
@torch.inference_mode()
|
78 |
def generate_image(
|
79 |
prompt: str,
|
|
|
250 |
|
251 |
|
252 |
def create_demo():
|
253 |
+
with gr.Blocks() as demo:
|
254 |
gr.Markdown("# PuLID: ์ธ๋ฌผ ์ด๋ฏธ์ง ๋ณํ ๋๊ตฌ")
|
255 |
|
256 |
if not model_initialized:
|
|
|
281 |
seed_output = gr.Textbox(label="๊ฒฐ๊ณผ/์ค๋ฅ ๋ฉ์์ง")
|
282 |
gr.Markdown(_CITE_)
|
283 |
|
284 |
+
# ์์ ์ถ๊ฐ
|
285 |
+
with gr.Row():
|
286 |
+
gr.Markdown("## ์์ ")
|
287 |
+
example_inps = [
|
288 |
+
[
|
289 |
+
'a portrait of a clown',
|
290 |
+
'example_inputs/unsplash/lhon-karwan-11tbHtK5STE-unsplash.jpg',
|
291 |
+
0.5, 3.5, "-1", 16, 0.4, "", 3.5, 0.5, 0.8
|
292 |
+
],
|
293 |
+
[
|
294 |
+
'a portrait of a zombie',
|
295 |
+
'example_inputs/unsplash/baruk-granda-cfLL_jHQ-Iw-unsplash.jpg',
|
296 |
+
0.4, 3.5, "42", 16, 0.4, "", 3.5, 0.5, 0.8
|
297 |
+
]
|
298 |
+
]
|
299 |
+
gr.Examples(
|
300 |
+
examples=example_inps,
|
301 |
+
inputs=[prompt, id_image, id_weight, guidance, seed, num_steps,
|
302 |
+
id_weight, neg_prompt, true_cfg, gamma, eta]
|
303 |
+
)
|
304 |
+
|
305 |
+
# Gradio ์ด๋ฒคํธ ์ฐ๊ฒฐ
|
306 |
generate_btn.click(
|
307 |
fn=generate_image,
|
308 |
inputs=[
|
|
|
324 |
parser.add_argument("--port", type=int, default=8080)
|
325 |
args = parser.parse_args()
|
326 |
|
327 |
+
print("Hugging Face Spaces ํ๊ฒฝ์์ ์คํ ์ค์
๋๋ค. GPU ํ ๋น์ ์์ฒญํฉ๋๋ค.")
|
328 |
+
|
329 |
demo = create_demo()
|
330 |
+
demo.queue(concurrency_count=1).launch(server_name="0.0.0.0", server_port=args.port)
|