Update app.py
Browse files
app.py
CHANGED
@@ -153,6 +153,7 @@ footer {
|
|
153 |
}
|
154 |
"""
|
155 |
|
|
|
156 |
def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_available() else "cpu",
|
157 |
offload: bool = False):
|
158 |
|
@@ -173,27 +174,21 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
|
|
173 |
gr.Markdown("### 스타일")
|
174 |
|
175 |
all_examples = [
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
]
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
gallery = gr.Gallery(
|
194 |
-
value=list(zip(example_images, example_captions)),
|
195 |
-
label="예시 갤러리",
|
196 |
-
show_label=False,
|
197 |
elem_id="gallery",
|
198 |
columns=5,
|
199 |
rows=2,
|
@@ -202,16 +197,16 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
|
|
202 |
)
|
203 |
|
204 |
def fill_example(evt: gr.SelectData):
|
205 |
-
return
|
206 |
|
207 |
-
|
208 |
fill_example,
|
209 |
None,
|
210 |
-
[prompt
|
211 |
)
|
212 |
|
213 |
generate_btn.click(
|
214 |
-
fn=lambda *args: generate_image(*args)[0], #
|
215 |
inputs=[
|
216 |
gr.Slider(256, 1536, 896, step=16, visible=False), # width
|
217 |
gr.Slider(256, 1536, 1152, step=16, visible=False), # height
|
@@ -232,6 +227,7 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
|
|
232 |
|
233 |
return demo
|
234 |
|
|
|
235 |
if __name__ == "__main__":
|
236 |
import argparse
|
237 |
|
|
|
153 |
}
|
154 |
"""
|
155 |
|
156 |
+
|
157 |
def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_available() else "cpu",
|
158 |
offload: bool = False):
|
159 |
|
|
|
174 |
gr.Markdown("### 스타일")
|
175 |
|
176 |
all_examples = [
|
177 |
+
["우주 여행I", 'I am an astronaut on a spacewalk. There is no helmet, and my face is visible. The background is Earth & starship as seen from space shuttle.', 'example_inputs/1.webp'],
|
178 |
+
["우주 여행II", 'I am an astronaut on a spacewalk. There is no helmet, and my face is visible. The background is Earth & starship as seen from space shuttle.I am holding sign with glowing green text "I Love Mom"', 'example_inputs/2.webp'],
|
179 |
+
["우주선 조종", 'I am wearing a spacesuit and have become an astronaut. I am piloting a spacecraft. Through the spacecraft's window, I can see outer space.', 'example_inputs/7.webp'],
|
180 |
+
["화성 탐험", 'I am wearing a spacesuit and have become an astronaut walking on Mars. I'm not wearing a helmet. I'm looking straight ahead. The background is a desolate area of Mars, and a space rover and a space station can be seen.', 'example_inputs/5.webp'],
|
181 |
+
["아이언맨 변신", 'I am an "IRON MAN"', 'example_inputs/4.webp'],
|
182 |
+
["스파이더맨", 'I am an "spider MAN"', 'example_inputs/6.webp'],
|
183 |
+
["만화 주인공", 'portrait, pixar style', 'example_inputs/8.webp'],
|
184 |
+
["원더우먼", 'I am an "wonder woman"', 'example_inputs/9.webp'],
|
185 |
+
["카우보이", 'Cowboy, american comics style', 'example_inputs/10.webp'],
|
186 |
+
["내가 어른이 되면", 'profile photo of a 40-year-old Adult Looking straight ahead, wear suite', 'example_inputs/3.webp'],
|
|
|
|
|
187 |
]
|
188 |
|
189 |
+
example_gallery = gr.Gallery(
|
190 |
+
[example[2] for example in all_examples],
|
191 |
+
label="스타일 예시",
|
|
|
|
|
|
|
|
|
192 |
elem_id="gallery",
|
193 |
columns=5,
|
194 |
rows=2,
|
|
|
197 |
)
|
198 |
|
199 |
def fill_example(evt: gr.SelectData):
|
200 |
+
return all_examples[evt.index][1]
|
201 |
|
202 |
+
example_gallery.select(
|
203 |
fill_example,
|
204 |
None,
|
205 |
+
[prompt],
|
206 |
)
|
207 |
|
208 |
generate_btn.click(
|
209 |
+
fn=lambda *args: generate_image(*args)[0], # 첫 번째 항목(이미지)만 반환
|
210 |
inputs=[
|
211 |
gr.Slider(256, 1536, 896, step=16, visible=False), # width
|
212 |
gr.Slider(256, 1536, 1152, step=16, visible=False), # height
|
|
|
227 |
|
228 |
return demo
|
229 |
|
230 |
+
|
231 |
if __name__ == "__main__":
|
232 |
import argparse
|
233 |
|