File size: 904 Bytes
3b6c254
1a76268
 
 
3b6c254
 
 
1a76268
 
 
 
 
 
 
f0a1f4f
1a76268
 
 
 
f0a1f4f
 
1a76268
 
 
3b6c254
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import streamlit as st
import torch
from diffusers import StableVideoDiffusionPipeline
from diffusers.utils import load_image, export_to_video

# Main function
def CREATEGIF():
    st.title("Create photoshoot visual video")

    pipeline = StableVideoDiffusionPipeline.from_pretrained(
        "stabilityai/stable-video-diffusion-img2vid-xt", torch_dtype=torch.float16, variant="fp16"
    )
    pipeline.enable_model_cpu_offload()

    image = load_image("Assets/output/images/overlay_image.png")
    image = image.resize((1024, 576))

    generator = torch.manual_seed(42)
    frames = pipeline(image, decode_chunk_size=8, generator=generator).frames[0]
    export_to_video(frames, "Assets/output/videos/generated.mp4", fps=7)
    video_file = open('Assets/output/videos/generated.mp4', 'rb')
    video_bytes = video_file.read()

    st.video(video_bytes)


if __name__ == "__main__":
    CREATEGIF()