utils.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:meta-learning 作者: ioanachelu 项目源码 文件源码
def make_gif(images, fname, duration=2, true_image=False):
    import moviepy.editor as mpy

    def make_frame(t):
        try:
            x = images[int(len(images) / duration * t)]
        except:
            x = images[-1]

        if true_image:
            return x.astype(np.uint8)
        else:
            return ((x + 1) / 2 * 255).astype(np.uint8)

    clip = mpy.VideoClip(make_frame, duration=duration)
    clip.write_gif(fname, fps=len(images) / duration, verbose=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号