Update app.py
Browse files
app.py
CHANGED
@@ -162,46 +162,26 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
|
|
162 |
with gr.Column():
|
163 |
prompt = gr.Textbox(label="Prompt", value="portrait, color, cinematic")
|
164 |
id_image = gr.Image(label="ID Image")
|
165 |
-
id_weight = gr.Slider(0.0, 3.0, 1, step=0.05, label="id weight")
|
166 |
-
|
167 |
-
width = gr.Slider(256, 1536, 896, step=16, label="Width")
|
168 |
-
height = gr.Slider(256, 1536, 1152, step=16, label="Height")
|
169 |
-
num_steps = gr.Slider(1, 20, 20, step=1, label="Number of steps")
|
170 |
-
start_step = gr.Slider(0, 10, 0, step=1, label="timestep to start inserting ID")
|
171 |
-
guidance = gr.Slider(1.0, 10.0, 4, step=0.1, label="Guidance")
|
172 |
-
seed = gr.Textbox(-1, label="Seed (-1 for random)")
|
173 |
-
max_sequence_length = gr.Slider(128, 512, 128, step=128,
|
174 |
-
label="max_sequence_length for prompt (T5), small will be faster")
|
175 |
-
|
176 |
-
with gr.Accordion("Advanced Options", open=False):
|
177 |
-
neg_prompt = gr.Textbox(
|
178 |
-
label="Negative Prompt",
|
179 |
-
value="bad quality, worst quality, text, signature, watermark, extra limbs")
|
180 |
-
true_cfg = gr.Slider(1.0, 10.0, 1, step=0.1, label="true CFG scale")
|
181 |
-
timestep_to_start_cfg = gr.Slider(0, 20, 1, step=1, label="timestep to start cfg", visible=args.dev)
|
182 |
-
|
183 |
generate_btn = gr.Button("Generate")
|
184 |
|
185 |
with gr.Column():
|
186 |
output_image = gr.Image(label="Generated Image")
|
187 |
-
seed_output = gr.Textbox(label="Used Seed")
|
188 |
-
intermediate_output = gr.Gallery(label='Output', elem_id="gallery", visible=args.dev)
|
189 |
|
190 |
with gr.Row():
|
191 |
with gr.Column():
|
192 |
gr.Markdown("## Examples")
|
193 |
|
194 |
all_examples = [
|
195 |
-
['a woman holding sign with glowing green text \"PuLID for FLUX\"', 'example_inputs/liuyifei.png'
|
196 |
-
['portrait, side view', 'example_inputs/liuyifei.png'
|
197 |
-
['white-haired woman with vr technology atmosphere
|
198 |
-
['a young child is eating Icecream', 'example_inputs/liuyifei.png'
|
199 |
-
['a man is holding a sign with text \"PuLID for FLUX\", winter, snowing
|
200 |
-
['portrait, candle light', 'example_inputs/pengwei.jpg'
|
201 |
-
['profile shot dark photo of a 25-year-old male with smoke
|
202 |
-
['American Comics, 1boy', 'example_inputs/pengwei.jpg'
|
203 |
-
['portrait, pixar', 'example_inputs/pengwei.jpg'
|
204 |
-
['portrait, made of ice sculpture', 'example_inputs/lecun.jpg'
|
205 |
]
|
206 |
|
207 |
example_images = [example[1] for example in all_examples]
|
@@ -219,19 +199,32 @@ def create_demo(args, model_name: str, device: str = "cuda" if torch.cuda.is_ava
|
|
219 |
)
|
220 |
|
221 |
def fill_example(evt: gr.SelectData):
|
222 |
-
return [all_examples[evt.index][i] for i in [0, 1
|
223 |
|
224 |
gallery.select(
|
225 |
fill_example,
|
226 |
None,
|
227 |
-
[prompt, id_image
|
228 |
)
|
229 |
|
230 |
generate_btn.click(
|
231 |
fn=generate_image,
|
232 |
-
inputs=[
|
233 |
-
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
)
|
236 |
|
237 |
return demo
|
|
|
162 |
with gr.Column():
|
163 |
prompt = gr.Textbox(label="Prompt", value="portrait, color, cinematic")
|
164 |
id_image = gr.Image(label="ID Image")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
generate_btn = gr.Button("Generate")
|
166 |
|
167 |
with gr.Column():
|
168 |
output_image = gr.Image(label="Generated Image")
|
|
|
|
|
169 |
|
170 |
with gr.Row():
|
171 |
with gr.Column():
|
172 |
gr.Markdown("## Examples")
|
173 |
|
174 |
all_examples = [
|
175 |
+
['a woman holding sign with glowing green text \"PuLID for FLUX\"', 'example_inputs/liuyifei.png'],
|
176 |
+
['portrait, side view', 'example_inputs/liuyifei.png'],
|
177 |
+
['white-haired woman with vr technology atmosphere', 'example_inputs/liuyifei.png'],
|
178 |
+
['a young child is eating Icecream', 'example_inputs/liuyifei.png'],
|
179 |
+
['a man is holding a sign with text \"PuLID for FLUX\", winter, snowing', 'example_inputs/pengwei.jpg'],
|
180 |
+
['portrait, candle light', 'example_inputs/pengwei.jpg'],
|
181 |
+
['profile shot dark photo of a 25-year-old male with smoke', 'example_inputs/pengwei.jpg'],
|
182 |
+
['American Comics, 1boy', 'example_inputs/pengwei.jpg'],
|
183 |
+
['portrait, pixar', 'example_inputs/pengwei.jpg'],
|
184 |
+
['portrait, made of ice sculpture', 'example_inputs/lecun.jpg'],
|
185 |
]
|
186 |
|
187 |
example_images = [example[1] for example in all_examples]
|
|
|
199 |
)
|
200 |
|
201 |
def fill_example(evt: gr.SelectData):
|
202 |
+
return [all_examples[evt.index][i] for i in [0, 1]]
|
203 |
|
204 |
gallery.select(
|
205 |
fill_example,
|
206 |
None,
|
207 |
+
[prompt, id_image],
|
208 |
)
|
209 |
|
210 |
generate_btn.click(
|
211 |
fn=generate_image,
|
212 |
+
inputs=[
|
213 |
+
gr.Slider(256, 1536, 896, step=16, visible=False), # width
|
214 |
+
gr.Slider(256, 1536, 1152, step=16, visible=False), # height
|
215 |
+
gr.Slider(1, 20, 20, step=1, visible=False), # num_steps
|
216 |
+
gr.Slider(0, 10, 0, step=1, visible=False), # start_step
|
217 |
+
gr.Slider(1.0, 10.0, 4, step=0.1, visible=False), # guidance
|
218 |
+
gr.Textbox(-1, visible=False), # seed
|
219 |
+
prompt,
|
220 |
+
id_image,
|
221 |
+
gr.Slider(0.0, 3.0, 1, step=0.05, visible=False), # id_weight
|
222 |
+
gr.Textbox("bad quality, worst quality, text, signature, watermark, extra limbs", visible=False), # neg_prompt
|
223 |
+
gr.Slider(1.0, 10.0, 1, step=0.1, visible=False), # true_cfg
|
224 |
+
gr.Slider(0, 20, 1, step=1, visible=False), # timestep_to_start_cfg
|
225 |
+
gr.Slider(128, 512, 128, step=128, visible=False), # max_sequence_length
|
226 |
+
],
|
227 |
+
outputs=[output_image],
|
228 |
)
|
229 |
|
230 |
return demo
|