Spaces:
Running
Running
Commit
•
1a76268
1
Parent(s):
3b6c254
Added Video code
Browse files- Pages/bgImages.py +1 -1
- Pages/createVideo.py +20 -43
- Pages/imageBB.py +1 -1
- requirements.txt +1 -0
Pages/bgImages.py
CHANGED
@@ -31,7 +31,7 @@ def BGIMAGES():
|
|
31 |
|
32 |
# Generate the image
|
33 |
with st.spinner("Generating image..."):
|
34 |
-
image_prompt = f"{prompt},
|
35 |
image = pipeline(image_prompt, generator=generator).images[0]
|
36 |
|
37 |
# Save the image
|
|
|
31 |
|
32 |
# Generate the image
|
33 |
with st.spinner("Generating image..."):
|
34 |
+
image_prompt = f"{prompt}, muted colors, detailed, 8k"
|
35 |
image = pipeline(image_prompt, generator=generator).images[0]
|
36 |
|
37 |
# Save the image
|
Pages/createVideo.py
CHANGED
@@ -1,50 +1,27 @@
|
|
1 |
-
from PIL import Image
|
2 |
import streamlit as st
|
3 |
-
import
|
|
|
|
|
4 |
|
5 |
# Main function
|
6 |
def CREATEGIF():
|
7 |
-
st.title("Create photoshoot visual")
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
image = Image.open(uploaded_file)
|
25 |
-
|
26 |
-
# Display the uploaded image
|
27 |
-
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
28 |
-
|
29 |
-
# Save the uploaded image to the specified directory
|
30 |
-
image_path = os.path.join(UPLOAD_DIR, uploaded_file.name)
|
31 |
-
image.save(image_path)
|
32 |
-
|
33 |
-
st.write(f"Image saved at: {image_path}")
|
34 |
-
|
35 |
-
else:
|
36 |
-
st.write("No image uploaded yet.")
|
37 |
-
|
38 |
-
image_files = [f for f in os.listdir("bgImages") if os.path.isfile(os.path.join("bgImages", f))]
|
39 |
-
|
40 |
-
# Create a dropdown with the list of image files
|
41 |
-
selected_image = st.selectbox("Select an image file", image_files)
|
42 |
-
|
43 |
-
if selected_image:
|
44 |
-
# Display the selected image
|
45 |
-
image_path = os.path.join("bgImages", selected_image)
|
46 |
-
image = Image.open(image_path)
|
47 |
-
st.image(image, caption=f"Selected image: {selected_image}")
|
48 |
|
49 |
|
50 |
if __name__ == "__main__":
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import torch
|
3 |
+
from diffusers import StableVideoDiffusionPipeline
|
4 |
+
from diffusers.utils import load_image, export_to_video
|
5 |
|
6 |
# Main function
|
7 |
def CREATEGIF():
|
8 |
+
st.title("Create photoshoot visual video")
|
9 |
+
|
10 |
+
pipeline = StableVideoDiffusionPipeline.from_pretrained(
|
11 |
+
"stabilityai/stable-video-diffusion-img2vid-xt", torch_dtype=torch.float16, variant="fp16"
|
12 |
+
)
|
13 |
+
pipeline.enable_model_cpu_offload()
|
14 |
+
|
15 |
+
image = load_image("output/overlay_image.png")
|
16 |
+
image = image.resize((1024, 576))
|
17 |
+
|
18 |
+
generator = torch.manual_seed(42)
|
19 |
+
frames = pipeline(image, decode_chunk_size=8, generator=generator).frames[0]
|
20 |
+
export_to_video(frames, "output/generated.mp4", fps=7)
|
21 |
+
video_file = open('output/generated.mp4', 'rb')
|
22 |
+
video_bytes = video_file.read()
|
23 |
+
|
24 |
+
st.video(video_bytes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
27 |
if __name__ == "__main__":
|
Pages/imageBB.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from segment_anything import sam_model_registry,
|
2 |
import torch
|
3 |
import streamlit as st
|
4 |
from Pages.streamlit_img_label import st_img_label
|
|
|
1 |
+
from segment_anything import sam_model_registry, SamPredictor
|
2 |
import torch
|
3 |
import streamlit as st
|
4 |
from Pages.streamlit_img_label import st_img_label
|
requirements.txt
CHANGED
@@ -7,3 +7,4 @@ pascal_voc_writer
|
|
7 |
roboflow
|
8 |
dataclasses-json
|
9 |
supervision
|
|
|
|
7 |
roboflow
|
8 |
dataclasses-json
|
9 |
supervision
|
10 |
+
torchvision
|