samcoding5854 commited on
Commit
e3c2cfd
1 Parent(s): 700c2ff

Added folder saving logics

Browse files
Files changed (2) hide show
  1. Pages/createVideo.py +4 -0
  2. Pages/imageBB.py +2 -0
Pages/createVideo.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
  import torch
3
  from diffusers import StableVideoDiffusionPipeline
4
  from diffusers.utils import load_image, export_to_video
@@ -17,6 +18,9 @@ def CREATEGIF():
17
 
18
  generator = torch.manual_seed(42)
19
  frames = pipeline(image, decode_chunk_size=8, generator=generator).frames[0]
 
 
 
20
  export_to_video(frames, "Assets/output/videos/generated.mp4", fps=7)
21
  video_file = open('Assets/output/videos/generated.mp4', 'rb')
22
  video_bytes = video_file.read()
 
1
  import streamlit as st
2
+ import os
3
  import torch
4
  from diffusers import StableVideoDiffusionPipeline
5
  from diffusers.utils import load_image, export_to_video
 
18
 
19
  generator = torch.manual_seed(42)
20
  frames = pipeline(image, decode_chunk_size=8, generator=generator).frames[0]
21
+
22
+ if not os.path.exists("Assets/output/videos"):
23
+ os.makedirs("Assets/output/videos")
24
  export_to_video(frames, "Assets/output/videos/generated.mp4", fps=7)
25
  video_file = open('Assets/output/videos/generated.mp4', 'rb')
26
  video_bytes = video_file.read()
Pages/imageBB.py CHANGED
@@ -152,6 +152,8 @@ def run(img_path):
152
  # Prompt user for the filename
153
  filename = st.text_input("Enter a name to save the image:")
154
  if filename and st.button("Save Image"):
 
 
155
  output_path = f'Assets/output/images/{filename}.png'
156
  cv2.imwrite(output_path, overlay_image)
157
 
 
152
  # Prompt user for the filename
153
  filename = st.text_input("Enter a name to save the image:")
154
  if filename and st.button("Save Image"):
155
+ if not os.path.exists("Assets/output/images"):
156
+ os.makedirs("Assets/output/images")
157
  output_path = f'Assets/output/images/{filename}.png'
158
  cv2.imwrite(output_path, overlay_image)
159