MCPcopy Create free account
hub / github.com/Francis-Rings/StableAnimator / export_to_gif

Function export_to_gif

train_single.py:350–369  ·  view source on GitHub ↗

Export a list of frames to a GIF. Args: - frames (list): List of frames (as numpy arrays or PIL Image objects). - output_gif_path (str): Path to save the output GIF. - duration_ms (int): Duration of each frame in milliseconds.

(frames, output_gif_path, fps)

Source from the content-addressed store, hash-verified

348
349
350def export_to_gif(frames, output_gif_path, fps):
351 """
352 Export a list of frames to a GIF.
353
354 Args:
355 - frames (list): List of frames (as numpy arrays or PIL Image objects).
356 - output_gif_path (str): Path to save the output GIF.
357 - duration_ms (int): Duration of each frame in milliseconds.
358
359 """
360 # Convert numpy arrays to PIL Images if needed
361 pil_frames = [Image.fromarray(frame) if isinstance(
362 frame, np.ndarray) else frame for frame in frames]
363
364 pil_frames[0].save(output_gif_path.replace('.mp4', '.gif'),
365 format='GIF',
366 append_images=pil_frames[1:],
367 save_all=True,
368 duration=125,
369 loop=0)
370
371
372def tensor_to_vae_latent(t, vae, scale=True):

Callers 1

log_validationFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected