Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -139,7 +139,7 @@ def infer(
|
|
139 |
print('-- filtered prompt --')
|
140 |
print(enhanced_prompt)
|
141 |
print('-- generating image --')
|
142 |
-
|
143 |
sd_image = pipe(
|
144 |
prompt=enhanced_prompt, # This conversion is fine
|
145 |
negative_prompt=negative_prompt,
|
@@ -168,37 +168,6 @@ css = """
|
|
168 |
}
|
169 |
"""
|
170 |
|
171 |
-
def repeat_infer(
|
172 |
-
prompt,
|
173 |
-
negative_prompt,
|
174 |
-
seed,
|
175 |
-
randomize_seed,
|
176 |
-
width,
|
177 |
-
height,
|
178 |
-
guidance_scale,
|
179 |
-
num_inference_steps,
|
180 |
-
num_iterations, # New input for number of iterations
|
181 |
-
):
|
182 |
-
i = 0
|
183 |
-
while i < num_iterations:
|
184 |
-
time.sleep(700) # Wait for 10 minutes (600 seconds)
|
185 |
-
result, seed, image_path, enhanced_prompt = infer(
|
186 |
-
prompt,
|
187 |
-
negative_prompt,
|
188 |
-
seed,
|
189 |
-
randomize_seed,
|
190 |
-
width,
|
191 |
-
height,
|
192 |
-
guidance_scale,
|
193 |
-
num_inference_steps,
|
194 |
-
)
|
195 |
-
|
196 |
-
# Optionally, you can add logic here to process the results of each iteration
|
197 |
-
# For example, you could display the image, save it with a different name, etc.
|
198 |
-
i += 1
|
199 |
-
return result, seed, image_path, enhanced_prompt
|
200 |
-
|
201 |
-
|
202 |
with gr.Blocks(css=css) as demo:
|
203 |
with gr.Column(elem_id="col-container"):
|
204 |
gr.Markdown(" # Text-to-Text-to-Image StableDiffusion 3.5 Medium (with refine)")
|
@@ -222,9 +191,6 @@ with gr.Blocks(css=css) as demo:
|
|
222 |
placeholder="Enter a negative prompt",
|
223 |
visible=False,
|
224 |
)
|
225 |
-
num_iterations = gr.Number(
|
226 |
-
value=1000,
|
227 |
-
label="Number of Iterations")
|
228 |
seed = gr.Slider(
|
229 |
label="Seed",
|
230 |
minimum=0,
|
|
|
139 |
print('-- filtered prompt --')
|
140 |
print(enhanced_prompt)
|
141 |
print('-- generating image --')
|
142 |
+
with torch.no_grad():
|
143 |
sd_image = pipe(
|
144 |
prompt=enhanced_prompt, # This conversion is fine
|
145 |
negative_prompt=negative_prompt,
|
|
|
168 |
}
|
169 |
"""
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
with gr.Blocks(css=css) as demo:
|
172 |
with gr.Column(elem_id="col-container"):
|
173 |
gr.Markdown(" # Text-to-Text-to-Image StableDiffusion 3.5 Medium (with refine)")
|
|
|
191 |
placeholder="Enter a negative prompt",
|
192 |
visible=False,
|
193 |
)
|
|
|
|
|
|
|
194 |
seed = gr.Slider(
|
195 |
label="Seed",
|
196 |
minimum=0,
|