Spaces:
openfree
/
Running on Zero

openfree commited on
Commit
e970ea2
โ€ข
1 Parent(s): 6b64eec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -63
app.py CHANGED
@@ -163,14 +163,12 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
163
 
164
  with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
165
 
166
-
167
  with gr.Row():
168
  with gr.Column():
169
  prompt = gr.Textbox(label="Prompt", value="portrait, color, cinematic")
170
  id_image = gr.Image(label="ID Image")
171
  id_weight = gr.Slider(0.0, 3.0, 1, step=0.05, label="id weight")
172
 
173
-
174
  width = gr.Slider(256, 1536, 896, step=16, label="Width")
175
  height = gr.Slider(256, 1536, 1152, step=16, label="Height")
176
  num_steps = gr.Slider(1, 20, 20, step=1, label="Number of steps")
@@ -193,70 +191,51 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
193
  output_image = gr.Image(label="Generated Image")
194
  seed_output = gr.Textbox(label="Used Seed")
195
  intermediate_output = gr.Gallery(label='Output', elem_id="gallery", visible=args.dev)
196
- # _CITE_ ๊ด€๋ จ ๋ถ€๋ถ„ ์ œ๊ฑฐ
197
-
198
 
199
- with gr.Row(), gr.Column():
 
200
  gr.Markdown("## Examples")
201
- example_inps = [
202
- [
203
- 'a woman holding sign with glowing green text \"PuLID for FLUX\"',
204
- 'example_inputs/liuyifei.png',
205
- 4, 4, 2680261499100305976, 1
206
- ],
207
- [
208
- 'portrait, side view',
209
- 'example_inputs/liuyifei.png',
210
- 4, 4, 1205240166692517553, 1
211
- ],
212
- [
213
- 'white-haired woman with vr technology atmosphere, revolutionary exceptional magnum with remarkable details', # noqa E501
214
- 'example_inputs/liuyifei.png',
215
- 4, 4, 6349424134217931066, 1
216
- ],
217
- [
218
- 'a young child is eating Icecream',
219
- 'example_inputs/liuyifei.png',
220
- 4, 4, 10606046113565776207, 1
221
- ],
222
- [
223
- 'a man is holding a sign with text \"PuLID for FLUX\", winter, snowing, top of the mountain',
224
- 'example_inputs/pengwei.jpg',
225
- 4, 4, 2410129802683836089, 1
226
- ],
227
- [
228
- 'portrait, candle light',
229
- 'example_inputs/pengwei.jpg',
230
- 4, 4, 17522759474323955700, 1
231
- ],
232
- [
233
- 'profile shot dark photo of a 25-year-old male with smoke escaping from his mouth, the backlit smoke gives the image an ephemeral quality, natural face, natural eyebrows, natural skin texture, award winning photo, highly detailed face, atmospheric lighting, film grain, monochrome', # noqa E501
234
- 'example_inputs/pengwei.jpg',
235
- 4, 4, 17733156847328193625, 1
236
- ],
237
- [
238
- 'American Comics, 1boy',
239
- 'example_inputs/pengwei.jpg',
240
- 1, 4, 13223174453874179686, 1
241
- ],
242
- [
243
- 'portrait, pixar',
244
- 'example_inputs/pengwei.jpg',
245
- 1, 4, 9445036702517583939, 1
246
- ],
247
- ]
248
- gr.Examples(examples=example_inps, inputs=[prompt, id_image, start_step, guidance, seed, true_cfg],
249
- label='fake CFG')
250
-
251
- example_inps = [
252
- [
253
- 'portrait, made of ice sculpture',
254
- 'example_inputs/lecun.jpg',
255
- 1, 1, 3811899118709451814, 5
256
- ],
257
  ]
258
- gr.Examples(examples=example_inps, inputs=[prompt, id_image, start_step, guidance, seed, true_cfg],
259
- label='true CFG')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
 
261
  generate_btn.click(
262
  fn=generate_image,
 
163
 
164
  with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
165
 
 
166
  with gr.Row():
167
  with gr.Column():
168
  prompt = gr.Textbox(label="Prompt", value="portrait, color, cinematic")
169
  id_image = gr.Image(label="ID Image")
170
  id_weight = gr.Slider(0.0, 3.0, 1, step=0.05, label="id weight")
171
 
 
172
  width = gr.Slider(256, 1536, 896, step=16, label="Width")
173
  height = gr.Slider(256, 1536, 1152, step=16, label="Height")
174
  num_steps = gr.Slider(1, 20, 20, step=1, label="Number of steps")
 
191
  output_image = gr.Image(label="Generated Image")
192
  seed_output = gr.Textbox(label="Used Seed")
193
  intermediate_output = gr.Gallery(label='Output', elem_id="gallery", visible=args.dev)
 
 
194
 
195
+ with gr.Row():
196
+ with gr.Column():
197
  gr.Markdown("## Examples")
198
+
199
+ # ๋ชจ๋“  ์˜ˆ์‹œ๋ฅผ ํ•˜๋‚˜์˜ ๋ฆฌ์ŠคํŠธ๋กœ ํ•ฉ์นฉ๋‹ˆ๋‹ค
200
+ all_examples = [
201
+ ['a woman holding sign with glowing green text \"PuLID for FLUX\"', 'example_inputs/liuyifei.png', 4, 4, 2680261499100305976, 1],
202
+ ['portrait, side view', 'example_inputs/liuyifei.png', 4, 4, 1205240166692517553, 1],
203
+ ['white-haired woman with vr technology atmosphere, revolutionary exceptional magnum with remarkable details', 'example_inputs/liuyifei.png', 4, 4, 6349424134217931066, 1],
204
+ ['a young child is eating Icecream', 'example_inputs/liuyifei.png', 4, 4, 10606046113565776207, 1],
205
+ ['a man is holding a sign with text \"PuLID for FLUX\", winter, snowing, top of the mountain', 'example_inputs/pengwei.jpg', 4, 4, 2410129802683836089, 1],
206
+ ['portrait, candle light', 'example_inputs/pengwei.jpg', 4, 4, 17522759474323955700, 1],
207
+ ['profile shot dark photo of a 25-year-old male with smoke escaping from his mouth, the backlit smoke gives the image an ephemeral quality, natural face, natural eyebrows, natural skin texture, award winning photo, highly detailed face, atmospheric lighting, film grain, monochrome', 'example_inputs/pengwei.jpg', 4, 4, 17733156847328193625, 1],
208
+ ['American Comics, 1boy', 'example_inputs/pengwei.jpg', 1, 4, 13223174453874179686, 1],
209
+ ['portrait, pixar', 'example_inputs/pengwei.jpg', 1, 4, 9445036702517583939, 1],
210
+ ['portrait, made of ice sculpture', 'example_inputs/lecun.jpg', 1, 1, 3811899118709451814, 5],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  ]
212
+
213
+ # ์˜ˆ์‹œ ์ด๋ฏธ์ง€์™€ ์บก์…˜์„ ์ค€๋น„ํ•ฉ๋‹ˆ๋‹ค
214
+ example_images = [example[1] for example in all_examples]
215
+ example_captions = [example[0] for example in all_examples]
216
+
217
+ # Gallery ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ทธ๋ฆฌ๋“œ ํ˜•ํƒœ๋กœ ์˜ˆ์‹œ๋“ค์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค
218
+ gallery = gr.Gallery(
219
+ label="Example Gallery",
220
+ show_label=False,
221
+ elem_id="gallery",
222
+ columns=5,
223
+ rows=2,
224
+ object_fit="contain",
225
+ height="auto"
226
+ ).style(grid=5, height="auto")
227
+
228
+ gallery.value = list(zip(example_images, example_captions))
229
+
230
+ # ์˜ˆ์‹œ ํด๋ฆญ ์‹œ ์ž…๋ ฅ ํ•„๋“œ์— ๊ฐ’์„ ์ฑ„์šฐ๋Š” ํ•จ์ˆ˜
231
+ def fill_example(evt: gr.SelectData):
232
+ return [all_examples[evt.index][i] for i in [0, 1, 2, 3, 4, 5]]
233
+
234
+ gallery.select(
235
+ fill_example,
236
+ None,
237
+ [prompt, id_image, start_step, guidance, seed, true_cfg],
238
+ )
239
 
240
  generate_btn.click(
241
  fn=generate_image,