Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
import torch
|
4 |
-
from
|
5 |
import numpy as np
|
6 |
import io
|
7 |
|
@@ -18,7 +18,8 @@ st.write("Upload an image to generate a video. You can also adjust settings for
|
|
18 |
@st.cache_resource
|
19 |
def load_model():
|
20 |
model_id = "stabilityai/stable-video-diffusion-img2vid-xt"
|
21 |
-
|
|
|
22 |
return pipe
|
23 |
|
24 |
pipe = load_model()
|
@@ -30,26 +31,22 @@ uploaded_image = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "pn
|
|
30 |
frame_count = st.slider("Number of frames", min_value=10, max_value=50, value=25, step=5)
|
31 |
|
32 |
if uploaded_image is not None:
|
33 |
-
image = Image.open(uploaded_image)
|
34 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
35 |
|
36 |
if st.button('Generate Video'):
|
37 |
# ุชุญููู ุงูุตูุฑุฉ ุฅูู ููุฏูู
|
38 |
with st.spinner("Generating video..."):
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
# ุชูููุฏ ุงูููุฏูู
|
43 |
-
video_frames = pipe(image_tensor, num_frames=frame_count).images
|
44 |
-
|
45 |
st.success("Video generated successfully!")
|
46 |
|
47 |
# ุนุฑุถ ุงูููุฏูู
|
48 |
-
|
49 |
-
video_frames[0].save(video_bytes, format="mp4")
|
50 |
-
st.video(video_bytes, format="video/mp4")
|
51 |
|
52 |
# ุชูุฒูู ุงูููุฏูู
|
|
|
|
|
53 |
st.download_button(label="Download Video", data=video_bytes.getvalue(), file_name="generated_video.mp4", mime="video/mp4")
|
54 |
|
55 |
# ุชูุฏูู
ุจุนุถ ุงูู
ุนููู
ุงุช ุญูู ุงููู
ูุฐุฌ
|
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
import torch
|
4 |
+
from transformers import pipeline
|
5 |
import numpy as np
|
6 |
import io
|
7 |
|
|
|
18 |
@st.cache_resource
|
19 |
def load_model():
|
20 |
model_id = "stabilityai/stable-video-diffusion-img2vid-xt"
|
21 |
+
# ุชุฃูุฏ ู
ู ุงุณุชุฎุฏุงู
ุงูููุงุณ ุงูุตุญูุญ ู
ู ู
ูุชุจุฉ transformers ุฅุฐุง ูุงู ู
ุชุงุญูุง
|
22 |
+
pipe = pipeline("image-to-video", model=model_id, torch_dtype=torch.float16).to("cuda")
|
23 |
return pipe
|
24 |
|
25 |
pipe = load_model()
|
|
|
31 |
frame_count = st.slider("Number of frames", min_value=10, max_value=50, value=25, step=5)
|
32 |
|
33 |
if uploaded_image is not None:
|
34 |
+
image = Image.open(uploaded_image)
|
35 |
st.image(image, caption='Uploaded Image', use_column_width=True)
|
36 |
|
37 |
if st.button('Generate Video'):
|
38 |
# ุชุญููู ุงูุตูุฑุฉ ุฅูู ููุฏูู
|
39 |
with st.spinner("Generating video..."):
|
40 |
+
video_frames = pipe(image, num_frames=frame_count)
|
41 |
+
|
|
|
|
|
|
|
|
|
42 |
st.success("Video generated successfully!")
|
43 |
|
44 |
# ุนุฑุถ ุงูููุฏูู
|
45 |
+
st.video(video_frames[0], format="video/mp4")
|
|
|
|
|
46 |
|
47 |
# ุชูุฒูู ุงูููุฏูู
|
48 |
+
video_bytes = io.BytesIO()
|
49 |
+
video_frames[0].save(video_bytes, format="mp4")
|
50 |
st.download_button(label="Download Video", data=video_bytes.getvalue(), file_name="generated_video.mp4", mime="video/mp4")
|
51 |
|
52 |
# ุชูุฏูู
ุจุนุถ ุงูู
ุนููู
ุงุช ุญูู ุงููู
ูุฐุฌ
|