File size: 1,734 Bytes
08164b1
 
87048a2
 
 
08164b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87048a2
08164b1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87048a2
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import streamlit as st
import replicate
import requests
from PIL import Image
from io import BytesIO

# Set the replicate API token
import os
os.environ["REPLICATE_API_TOKEN"] = "r8_JSR8xlRoCk6cmq3qEOOThVTn3dAgdPq1bWXdj"

def run_replicate_model(input_params):
    output = replicate.run(
        "stability-ai/stable-video-diffusion:3f0457e4619daac51203dedb472816fd4af51f3149fa7a9e0b5ffcf1b8172438",
        input=input_params
    )
    return output

st.title("Stable Video Diffusion")
st.write("Fill in the input parameters and click on the button to run the Stable Video Diffusion model.")

cond_aug = st.number_input("Conditioning Augmentation", value=0.02)
decoding_t = st.number_input("Decoding Time", value=7)
input_image = st.text_input("Input Image URL", "https://example.com/s-widua-icjKmXvsO7U-unsplash.jpg")
video_length = st.selectbox("Video Length", ["14_frames_with_svd", "25_frames_with_svd_xt"])
sizing_strategy = st.selectbox("Sizing Strategy", ["maintain_aspect_ratio", "other_options"])
motion_bucket_id = st.number_input("Motion Bucket ID", value=127)
frames_per_second = st.number_input("Frames Per Second", value=6)

input_params = {
    "cond_aug": cond_aug,
    "decoding_t": decoding_t,
    "input_image": input_image,
    "video_length": video_length,
    "sizing_strategy": sizing_strategy,
    "motion_bucket_id": motion_bucket_id,
    "frames_per_second": frames_per_second
}

if st.button("Run Model"):
    output_result = run_replicate_model(input_params)
    st.write("Output Video:")
    
    try:
        response = requests.get(output_result)
        video_bytes = BytesIO(response.content)
        st.video(video_bytes)
    except Exception as e:
        st.write("Unable to display the video.")