Spaces:
Running
on
Zero
Running
on
Zero
This PR adds the "Guidance Scale" parameter
#2
by
Fabrice-TIERCELIN
- opened
app.py
CHANGED
@@ -19,7 +19,7 @@ pipe = FluxInpaintPipeline.from_pretrained(
|
|
19 |
"black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
|
20 |
|
21 |
@spaces.GPU()
|
22 |
-
def process(input_image_editor, uploaded_mask, input_text, strength, seed, randomize_seed, num_inference_steps, progress=gr.Progress(track_tqdm=True)):
|
23 |
if not input_text:
|
24 |
raise gr.Error("Please enter a text prompt.")
|
25 |
|
@@ -49,7 +49,8 @@ def process(input_image_editor, uploaded_mask, input_text, strength, seed, rando
|
|
49 |
height=height,
|
50 |
strength=strength,
|
51 |
num_inference_steps=num_inference_steps,
|
52 |
-
generator=generator
|
|
|
53 |
).images[0]
|
54 |
|
55 |
return result, mask_image, seed
|
@@ -80,12 +81,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
80 |
step=0.01,
|
81 |
label="Strength"
|
82 |
)
|
83 |
-
seed_number = gr.Number(
|
84 |
-
label="Seed",
|
85 |
-
value=42,
|
86 |
-
precision=0
|
87 |
-
)
|
88 |
-
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
89 |
num_inference_steps = gr.Slider(
|
90 |
minimum=1,
|
91 |
maximum=100,
|
@@ -93,10 +88,23 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
93 |
step=1,
|
94 |
label="Number of inference steps"
|
95 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
with gr.Accordion("Upload a mask", open=False):
|
97 |
uploaded_mask_component = gr.Image(label="Already made mask (black pixels will be preserved, white pixels will be redrawn)", sources=["upload"], type="pil")
|
98 |
submit_button_component = gr.Button(
|
99 |
-
value='
|
100 |
with gr.Column(scale=1):
|
101 |
output_image_component = gr.Image(
|
102 |
type='pil', image_mode='RGB', label='Generated image')
|
@@ -114,7 +122,8 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
114 |
strength_slider,
|
115 |
seed_number,
|
116 |
randomize_seed,
|
117 |
-
num_inference_steps
|
|
|
118 |
],
|
119 |
outputs=[
|
120 |
output_image_component,
|
|
|
19 |
"black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to(DEVICE)
|
20 |
|
21 |
@spaces.GPU()
|
22 |
+
def process(input_image_editor, uploaded_mask, input_text, strength, seed, randomize_seed, num_inference_steps, guidance_scale=3.5, progress=gr.Progress(track_tqdm=True)):
|
23 |
if not input_text:
|
24 |
raise gr.Error("Please enter a text prompt.")
|
25 |
|
|
|
49 |
height=height,
|
50 |
strength=strength,
|
51 |
num_inference_steps=num_inference_steps,
|
52 |
+
generator=generator,
|
53 |
+
guidance_scale=guidance_scale
|
54 |
).images[0]
|
55 |
|
56 |
return result, mask_image, seed
|
|
|
81 |
step=0.01,
|
82 |
label="Strength"
|
83 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
num_inference_steps = gr.Slider(
|
85 |
minimum=1,
|
86 |
maximum=100,
|
|
|
88 |
step=1,
|
89 |
label="Number of inference steps"
|
90 |
)
|
91 |
+
guidance_scale = gr.Slider(
|
92 |
+
label="Guidance Scale",
|
93 |
+
minimum=1,
|
94 |
+
maximum=15,
|
95 |
+
step=0.1,
|
96 |
+
value=3.5,
|
97 |
+
)
|
98 |
+
seed_number = gr.Number(
|
99 |
+
label="Seed",
|
100 |
+
value=42,
|
101 |
+
precision=0
|
102 |
+
)
|
103 |
+
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
104 |
with gr.Accordion("Upload a mask", open=False):
|
105 |
uploaded_mask_component = gr.Image(label="Already made mask (black pixels will be preserved, white pixels will be redrawn)", sources=["upload"], type="pil")
|
106 |
submit_button_component = gr.Button(
|
107 |
+
value='Inpaint', variant='primary')
|
108 |
with gr.Column(scale=1):
|
109 |
output_image_component = gr.Image(
|
110 |
type='pil', image_mode='RGB', label='Generated image')
|
|
|
122 |
strength_slider,
|
123 |
seed_number,
|
124 |
randomize_seed,
|
125 |
+
num_inference_steps,
|
126 |
+
guidance_scale
|
127 |
],
|
128 |
outputs=[
|
129 |
output_image_component,
|