Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -57,32 +57,35 @@ MAX_IMAGE_SIZE = 1024
|
|
57 |
|
58 |
@spaces.GPU
|
59 |
def infer(prompt,
|
60 |
-
ip_adapter_image
|
61 |
-
ip_adapter_scale
|
62 |
-
negative_prompt
|
63 |
-
seed
|
64 |
-
randomize_seed
|
65 |
-
width
|
66 |
-
height
|
67 |
-
guidance_scale
|
68 |
-
num_inference_steps
|
69 |
-
):
|
70 |
if randomize_seed:
|
71 |
seed = random.randint(0, MAX_SEED)
|
72 |
generator = torch.Generator().manual_seed(seed)
|
73 |
|
|
|
|
|
|
|
|
|
74 |
if ip_adapter_image is None:
|
75 |
pipe_t2i.to(device)
|
76 |
image = pipe_t2i(
|
77 |
-
prompt
|
78 |
-
negative_prompt
|
79 |
-
guidance_scale
|
80 |
-
num_inference_steps
|
81 |
-
width
|
82 |
-
height
|
83 |
-
generator
|
84 |
-
).images[0]
|
85 |
-
image.save("generated_image.jpg")
|
86 |
return image, "generated_image.jpg"
|
87 |
else:
|
88 |
pipe_i2i.to(device)
|
@@ -93,14 +96,14 @@ def infer(prompt,
|
|
93 |
prompt=prompt,
|
94 |
ip_adapter_image=[ip_adapter_image],
|
95 |
negative_prompt=negative_prompt,
|
96 |
-
height=height, #
|
97 |
-
width=width, #
|
98 |
num_inference_steps=num_inference_steps,
|
99 |
guidance_scale=guidance_scale,
|
100 |
num_images_per_prompt=1,
|
101 |
generator=generator
|
102 |
).images[0]
|
103 |
-
image.save("generated_image.jpg")
|
104 |
return image, "generated_image.jpg"
|
105 |
|
106 |
css="""
|
@@ -120,7 +123,7 @@ with gr.Blocks(css=css) as Kolors:
|
|
120 |
with gr.Row():
|
121 |
generated_prompt = gr.Textbox(
|
122 |
label="ํ๋กฌํํธ ์
๋ ฅ",
|
123 |
-
placeholder="์ด๋ฏธ์ง ์์ฑ์ ์ฌ์ฉํ ํ๋กฌํํธ๋ฅผ
|
124 |
lines=2
|
125 |
)
|
126 |
with gr.Row():
|
@@ -199,6 +202,4 @@ with gr.Blocks(css=css) as Kolors:
|
|
199 |
outputs=[result, download_button]
|
200 |
)
|
201 |
|
202 |
-
Kolors.queue().launch(debug=True)
|
203 |
-
|
204 |
-
|
|
|
57 |
|
58 |
@spaces.GPU
|
59 |
def infer(prompt,
|
60 |
+
ip_adapter_image=None,
|
61 |
+
ip_adapter_scale=0.5,
|
62 |
+
negative_prompt="",
|
63 |
+
seed=0,
|
64 |
+
randomize_seed=False,
|
65 |
+
width=1024,
|
66 |
+
height=1024,
|
67 |
+
guidance_scale=5.0,
|
68 |
+
num_inference_steps=25):
|
|
|
69 |
if randomize_seed:
|
70 |
seed = random.randint(0, MAX_SEED)
|
71 |
generator = torch.Generator().manual_seed(seed)
|
72 |
|
73 |
+
# width์ height๋ฅผ 8์ ๋ฐฐ์๋ก ์กฐ์
|
74 |
+
width = (width // 8) * 8
|
75 |
+
height = (height // 8) * 8
|
76 |
+
|
77 |
if ip_adapter_image is None:
|
78 |
pipe_t2i.to(device)
|
79 |
image = pipe_t2i(
|
80 |
+
prompt=prompt,
|
81 |
+
negative_prompt=negative_prompt,
|
82 |
+
guidance_scale=guidance_scale,
|
83 |
+
num_inference_steps=num_inference_steps,
|
84 |
+
width=width, # ์กฐ์ ๋ ๊ฐ์ ์ฌ์ฉ
|
85 |
+
height=height, # ์กฐ์ ๋ ๊ฐ์ ์ฌ์ฉ
|
86 |
+
generator=generator
|
87 |
+
).images[0]
|
88 |
+
image.save("generated_image.jpg")
|
89 |
return image, "generated_image.jpg"
|
90 |
else:
|
91 |
pipe_i2i.to(device)
|
|
|
96 |
prompt=prompt,
|
97 |
ip_adapter_image=[ip_adapter_image],
|
98 |
negative_prompt=negative_prompt,
|
99 |
+
height=height, # ์กฐ์ ๋ ๊ฐ์ ์ฌ์ฉ
|
100 |
+
width=width, # ์กฐ์ ๋ ๊ฐ์ ์ฌ์ฉ
|
101 |
num_inference_steps=num_inference_steps,
|
102 |
guidance_scale=guidance_scale,
|
103 |
num_images_per_prompt=1,
|
104 |
generator=generator
|
105 |
).images[0]
|
106 |
+
image.save("generated_image.jpg")
|
107 |
return image, "generated_image.jpg"
|
108 |
|
109 |
css="""
|
|
|
123 |
with gr.Row():
|
124 |
generated_prompt = gr.Textbox(
|
125 |
label="ํ๋กฌํํธ ์
๋ ฅ",
|
126 |
+
placeholder="์ด๋ฏธ์ง ์์ฑ์ ์ฌ์ฉํ ํ๋กฌํํธ๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์.",
|
127 |
lines=2
|
128 |
)
|
129 |
with gr.Row():
|
|
|
202 |
outputs=[result, download_button]
|
203 |
)
|
204 |
|
205 |
+
Kolors.queue().launch(debug=True)
|
|
|
|