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

Function export_to_gif

train.py:346–365  ·  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

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

Callers 1

log_validationFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected