Spaces:
Runtime error
Runtime error
add gif output
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ from PIL import Image
|
|
9 |
from diffusers.utils import load_image
|
10 |
from diffusers.pipelines.flux.pipeline_flux_controlnet import FluxControlNetPipeline
|
11 |
from diffusers.models.controlnet_flux import FluxControlNetModel
|
12 |
-
|
13 |
|
14 |
def process_controlnet_img(image):
|
15 |
controlnet_img = np.array(image)
|
@@ -82,16 +82,26 @@ def update_scales(x,prompt,seed, steps, guidance_scale,
|
|
82 |
controlnet_scale= None, ip_adapter_scale=None,):
|
83 |
print("Hola", x)
|
84 |
avg_diff = avg_diff_x.cuda()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
if img2img_type=="controlnet canny" and img is not None:
|
86 |
control_img = process_controlnet_img(img)
|
87 |
image = t5_slider_controlnet.generate(prompt, guidance_scale=guidance_scale, image=control_img, controlnet_conditioning_scale =controlnet_scale, scale=x, seed=seed, num_inference_steps=steps, avg_diff=avg_diff)
|
88 |
elif img2img_type=="ip adapter" and img is not None:
|
89 |
image = clip_slider.generate(prompt, guidance_scale=guidance_scale, ip_adapter_image=img, scale=x,seed=seed, num_inference_steps=steps, avg_diff=avg_diff)
|
90 |
-
else:
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
95 |
|
96 |
|
97 |
def reset_recalc_directions():
|
|
|
9 |
from diffusers.utils import load_image
|
10 |
from diffusers.pipelines.flux.pipeline_flux_controlnet import FluxControlNetPipeline
|
11 |
from diffusers.models.controlnet_flux import FluxControlNetModel
|
12 |
+
from diffusers.utils import export_to_gif
|
13 |
|
14 |
def process_controlnet_img(image):
|
15 |
controlnet_img = np.array(image)
|
|
|
82 |
controlnet_scale= None, ip_adapter_scale=None,):
|
83 |
print("Hola", x)
|
84 |
avg_diff = avg_diff_x.cuda()
|
85 |
+
|
86 |
+
# for spectrum generation
|
87 |
+
images = []
|
88 |
+
steps=5
|
89 |
+
high_scale = x if x > 0 else abs(max(x, -3))
|
90 |
+
low_scale = x if x < 0 else x * (-1)
|
91 |
+
|
92 |
if img2img_type=="controlnet canny" and img is not None:
|
93 |
control_img = process_controlnet_img(img)
|
94 |
image = t5_slider_controlnet.generate(prompt, guidance_scale=guidance_scale, image=control_img, controlnet_conditioning_scale =controlnet_scale, scale=x, seed=seed, num_inference_steps=steps, avg_diff=avg_diff)
|
95 |
elif img2img_type=="ip adapter" and img is not None:
|
96 |
image = clip_slider.generate(prompt, guidance_scale=guidance_scale, ip_adapter_image=img, scale=x,seed=seed, num_inference_steps=steps, avg_diff=avg_diff)
|
97 |
+
else:
|
98 |
+
for i in range(steps):
|
99 |
+
cur_scale = low_scale + (high_scale - low_scale) * i / (steps - 1)
|
100 |
+
image = clip_slider.generate(prompt,
|
101 |
+
#guidance_scale=guidance_scale,
|
102 |
+
scale=cur_scale, seed=seed, num_inference_steps=steps, avg_diff=avg_diff)
|
103 |
+
images.apped(image)
|
104 |
+
return export_to_gif(images, "clip.gif", fps=5)
|
105 |
|
106 |
|
107 |
def reset_recalc_directions():
|