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

Function export_to_gif

inference_basic.py:58–77  ·  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

56
57
58def export_to_gif(frames, output_gif_path, fps):
59 """
60 Export a list of frames to a GIF.
61
62 Args:
63 - frames (list): List of frames (as numpy arrays or PIL Image objects).
64 - output_gif_path (str): Path to save the output GIF.
65 - duration_ms (int): Duration of each frame in milliseconds.
66
67 """
68 # Convert numpy arrays to PIL Images if needed
69 pil_frames = [Image.fromarray(frame) if isinstance(
70 frame, np.ndarray) else frame for frame in frames]
71
72 pil_frames[0].save(output_gif_path.replace('.mp4', '.gif'),
73 format='GIF',
74 append_images=pil_frames[1:],
75 save_all=True,
76 duration=125,
77 loop=0)
78
79def parse_args():
80 parser = argparse.ArgumentParser(

Callers 1

inference_basic.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected