Update app.py
Browse files
app.py
CHANGED
|
@@ -195,7 +195,48 @@ def delete_old_files():
|
|
| 195 |
time.sleep(600)
|
| 196 |
|
| 197 |
|
| 198 |
-
threading.Thread(target=delete_old_files, daemon=True).start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
examples_images = [
|
| 200 |
["asserts/example_images/1.png", "A woman adorned with a delicate flower crown, is standing amidst a field of gently swaying wildflowers. Her eyes sparkle with a serene gaze, and a faint smile graces her lips, suggesting a moment of peaceful contentment. The shot is framed from the waist up, highlighting the gentle breeze lightly tousling her hair. The background reveals an expansive meadow under a bright blue sky, capturing the tranquility of a sunny afternoon."],
|
| 201 |
["asserts/example_images/2.png", "The video captures a boy walking along a city street, filmed in black and white on a classic 35mm camera. His expression is thoughtful, his brow slightly furrowed as if he's lost in contemplation. The film grain adds a textured, timeless quality to the image, evoking a sense of nostalgia. Around him, the cityscape is filled with vintage buildings, cobblestone sidewalks, and softly blurred figures passing by, their outlines faint and indistinct. Streetlights cast a gentle glow, while shadows play across the boy's path, adding depth to the scene. The lighting highlights the boy's subtle smile, hinting at a fleeting moment of curiosity. The overall cinematic atmosphere, complete with classic film still aesthetics and dramatic contrasts, gives the scene an evocative and introspective feel."],
|
|
@@ -321,45 +362,7 @@ with gr.Blocks() as demo:
|
|
| 321 |
</tr>
|
| 322 |
</table>
|
| 323 |
""")
|
| 324 |
-
|
| 325 |
-
def generate(
|
| 326 |
-
prompt,
|
| 327 |
-
image_input,
|
| 328 |
-
seed_value,
|
| 329 |
-
scale_status,
|
| 330 |
-
rife_status,
|
| 331 |
-
progress=gr.Progress(track_tqdm=True)
|
| 332 |
-
):
|
| 333 |
-
latents, seed = infer(
|
| 334 |
-
prompt,
|
| 335 |
-
image_input,
|
| 336 |
-
num_inference_steps=5,
|
| 337 |
-
guidance_scale=7.0,
|
| 338 |
-
seed=seed_value,
|
| 339 |
-
progress=progress,
|
| 340 |
-
)
|
| 341 |
-
if scale_status:
|
| 342 |
-
latents = upscale_batch_and_concatenate(upscale_model, latents, device)
|
| 343 |
-
if rife_status:
|
| 344 |
-
latents = rife_inference_with_latents(frame_interpolation_model, latents)
|
| 345 |
-
|
| 346 |
-
batch_size = latents.shape[0]
|
| 347 |
-
batch_video_frames = []
|
| 348 |
-
for batch_idx in range(batch_size):
|
| 349 |
-
pt_image = latents[batch_idx]
|
| 350 |
-
pt_image = torch.stack([pt_image[i] for i in range(pt_image.shape[0])])
|
| 351 |
-
|
| 352 |
-
image_np = VaeImageProcessor.pt_to_numpy(pt_image)
|
| 353 |
-
image_pil = VaeImageProcessor.numpy_to_pil(image_np)
|
| 354 |
-
batch_video_frames.append(image_pil)
|
| 355 |
-
|
| 356 |
-
video_path = save_video(batch_video_frames[0], fps=math.ceil((len(batch_video_frames[0]) - 1) / 6))
|
| 357 |
-
video_update = gr.update(visible=True, value=video_path)
|
| 358 |
-
gif_path = convert_to_gif(video_path)
|
| 359 |
-
gif_update = gr.update(visible=True, value=gif_path)
|
| 360 |
-
seed_update = gr.update(visible=True, value=seed)
|
| 361 |
-
|
| 362 |
-
return video_path, video_update, gif_update, seed_update
|
| 363 |
|
| 364 |
generate_button.click(
|
| 365 |
generate,
|
|
@@ -367,6 +370,5 @@ with gr.Blocks() as demo:
|
|
| 367 |
outputs=[video_output, download_video_button, download_gif_button, seed_text],
|
| 368 |
)
|
| 369 |
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
demo.launch(debug=True)
|
|
|
|
| 195 |
time.sleep(600)
|
| 196 |
|
| 197 |
|
| 198 |
+
##threading.Thread(target=delete_old_files, daemon=True).start()
|
| 199 |
+
@spaces.GPU
|
| 200 |
+
def generate(
|
| 201 |
+
prompt,
|
| 202 |
+
image_input,
|
| 203 |
+
seed_value,
|
| 204 |
+
scale_status,
|
| 205 |
+
rife_status,
|
| 206 |
+
progress=gr.Progress(track_tqdm=True)
|
| 207 |
+
):
|
| 208 |
+
latents, seed = infer(
|
| 209 |
+
prompt,
|
| 210 |
+
image_input,
|
| 211 |
+
num_inference_steps=5,
|
| 212 |
+
guidance_scale=7.0,
|
| 213 |
+
seed=seed_value,
|
| 214 |
+
progress=progress,
|
| 215 |
+
)
|
| 216 |
+
if scale_status:
|
| 217 |
+
latents = upscale_batch_and_concatenate(upscale_model, latents, device)
|
| 218 |
+
if rife_status:
|
| 219 |
+
latents = rife_inference_with_latents(frame_interpolation_model, latents)
|
| 220 |
+
|
| 221 |
+
batch_size = latents.shape[0]
|
| 222 |
+
batch_video_frames = []
|
| 223 |
+
for batch_idx in range(batch_size):
|
| 224 |
+
pt_image = latents[batch_idx]
|
| 225 |
+
pt_image = torch.stack([pt_image[i] for i in range(pt_image.shape[0])])
|
| 226 |
+
|
| 227 |
+
image_np = VaeImageProcessor.pt_to_numpy(pt_image)
|
| 228 |
+
image_pil = VaeImageProcessor.numpy_to_pil(image_np)
|
| 229 |
+
batch_video_frames.append(image_pil)
|
| 230 |
+
|
| 231 |
+
video_path = save_video(batch_video_frames[0], fps=math.ceil((len(batch_video_frames[0]) - 1) / 6))
|
| 232 |
+
video_update = gr.update(visible=True, value=video_path)
|
| 233 |
+
gif_path = convert_to_gif(video_path)
|
| 234 |
+
gif_update = gr.update(visible=True, value=gif_path)
|
| 235 |
+
seed_update = gr.update(visible=True, value=seed)
|
| 236 |
+
|
| 237 |
+
return video_path, video_update, gif_update, seed_update
|
| 238 |
+
|
| 239 |
+
|
| 240 |
examples_images = [
|
| 241 |
["asserts/example_images/1.png", "A woman adorned with a delicate flower crown, is standing amidst a field of gently swaying wildflowers. Her eyes sparkle with a serene gaze, and a faint smile graces her lips, suggesting a moment of peaceful contentment. The shot is framed from the waist up, highlighting the gentle breeze lightly tousling her hair. The background reveals an expansive meadow under a bright blue sky, capturing the tranquility of a sunny afternoon."],
|
| 242 |
["asserts/example_images/2.png", "The video captures a boy walking along a city street, filmed in black and white on a classic 35mm camera. His expression is thoughtful, his brow slightly furrowed as if he's lost in contemplation. The film grain adds a textured, timeless quality to the image, evoking a sense of nostalgia. Around him, the cityscape is filled with vintage buildings, cobblestone sidewalks, and softly blurred figures passing by, their outlines faint and indistinct. Streetlights cast a gentle glow, while shadows play across the boy's path, adding depth to the scene. The lighting highlights the boy's subtle smile, hinting at a fleeting moment of curiosity. The overall cinematic atmosphere, complete with classic film still aesthetics and dramatic contrasts, gives the scene an evocative and introspective feel."],
|
|
|
|
| 362 |
</tr>
|
| 363 |
</table>
|
| 364 |
""")
|
| 365 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
|
| 367 |
generate_button.click(
|
| 368 |
generate,
|
|
|
|
| 370 |
outputs=[video_output, download_video_button, download_gif_button, seed_text],
|
| 371 |
)
|
| 372 |
|
| 373 |
+
demo.queue(max_size=15)
|
| 374 |
+
demo.launch(debug=True)
|
|
|