Spaces:
Build error
Build error
image_init feature
Browse files
zoom.py
CHANGED
@@ -33,6 +33,7 @@ def zoom(
|
|
33 |
num_outpainting_steps,
|
34 |
guidance_scale,
|
35 |
num_inference_steps,
|
|
|
36 |
):
|
37 |
|
38 |
pipe = StableDiffusionInpaintPipeline.from_pretrained(
|
@@ -56,22 +57,20 @@ def zoom(
|
|
56 |
mask_image = np.array(current_image)[:, :, 3]
|
57 |
mask_image = Image.fromarray(255-mask_image).convert("RGB")
|
58 |
current_image = current_image.convert("RGB")
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
69 |
mask_width = 128
|
70 |
num_interpol_frames = 30
|
71 |
-
if (custom_init_image):
|
72 |
-
current_image = load_img(init_image_address, (width, height))
|
73 |
-
else:
|
74 |
-
current_image = init_images[0]
|
75 |
|
76 |
all_frames = []
|
77 |
all_frames.append(current_image)
|
@@ -128,7 +127,6 @@ def zoom(
|
|
128 |
all_frames.append(interpol_image)
|
129 |
|
130 |
all_frames.append(current_image)
|
131 |
-
|
132 |
video_file_name = "infinite_zoom_" + str(time.time())
|
133 |
fps = 30
|
134 |
save_path = video_file_name + ".mp4"
|
@@ -139,7 +137,6 @@ def zoom(
|
|
139 |
start_frame_dupe_amount, last_frame_dupe_amount)
|
140 |
return save_path
|
141 |
|
142 |
-
|
143 |
def zoom_app():
|
144 |
with gr.Blocks():
|
145 |
with gr.Row():
|
@@ -186,9 +183,9 @@ def zoom_app():
|
|
186 |
value=50,
|
187 |
label='Sampling Steps for each outpaint'
|
188 |
)
|
189 |
-
|
190 |
generate_btn = gr.Button(value='Generate video')
|
191 |
-
|
192 |
with gr.Column():
|
193 |
output_image = gr.Video(label='Output', format="mp4").style(
|
194 |
width=512, height=512)
|
@@ -201,7 +198,8 @@ def zoom_app():
|
|
201 |
outpaint_negative_prompt,
|
202 |
outpaint_steps,
|
203 |
guidance_scale,
|
204 |
-
sampling_step
|
|
|
205 |
],
|
206 |
outputs=output_image,
|
207 |
)
|
|
|
33 |
num_outpainting_steps,
|
34 |
guidance_scale,
|
35 |
num_inference_steps,
|
36 |
+
custom_init_image
|
37 |
):
|
38 |
|
39 |
pipe = StableDiffusionInpaintPipeline.from_pretrained(
|
|
|
57 |
mask_image = np.array(current_image)[:, :, 3]
|
58 |
mask_image = Image.fromarray(255-mask_image).convert("RGB")
|
59 |
current_image = current_image.convert("RGB")
|
60 |
+
if(custom_init_image):
|
61 |
+
current_image = custom_init_image.resize((width, height), resample=Image.LANCZOS)
|
62 |
+
else:
|
63 |
+
init_images = pipe(prompt=prompt, # TODO: prompt=prompts[max(k for k in prompts.keys() if k >= 0)],
|
64 |
+
negative_prompt=negative_prompt,
|
65 |
+
image=current_image,
|
66 |
+
guidance_scale=guidance_scale,
|
67 |
+
height=height,
|
68 |
+
width=width,
|
69 |
+
mask_image=mask_image,
|
70 |
+
num_inference_steps=num_inference_steps)[0]
|
71 |
+
current_image = init_images[0]
|
72 |
mask_width = 128
|
73 |
num_interpol_frames = 30
|
|
|
|
|
|
|
|
|
74 |
|
75 |
all_frames = []
|
76 |
all_frames.append(current_image)
|
|
|
127 |
all_frames.append(interpol_image)
|
128 |
|
129 |
all_frames.append(current_image)
|
|
|
130 |
video_file_name = "infinite_zoom_" + str(time.time())
|
131 |
fps = 30
|
132 |
save_path = video_file_name + ".mp4"
|
|
|
137 |
start_frame_dupe_amount, last_frame_dupe_amount)
|
138 |
return save_path
|
139 |
|
|
|
140 |
def zoom_app():
|
141 |
with gr.Blocks():
|
142 |
with gr.Row():
|
|
|
183 |
value=50,
|
184 |
label='Sampling Steps for each outpaint'
|
185 |
)
|
186 |
+
init_image = gr.Image(type="pil")
|
187 |
generate_btn = gr.Button(value='Generate video')
|
188 |
+
|
189 |
with gr.Column():
|
190 |
output_image = gr.Video(label='Output', format="mp4").style(
|
191 |
width=512, height=512)
|
|
|
198 |
outpaint_negative_prompt,
|
199 |
outpaint_steps,
|
200 |
guidance_scale,
|
201 |
+
sampling_step,
|
202 |
+
init_image
|
203 |
],
|
204 |
outputs=output_image,
|
205 |
)
|