Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -64,7 +64,7 @@ pipe.to("cuda")
|
|
64 |
|
65 |
max_64_bit_int = 2**63 - 1
|
66 |
|
67 |
-
@spaces.GPU(duration=
|
68 |
def generate_video(
|
69 |
image: Image,
|
70 |
seed: int,
|
@@ -97,17 +97,18 @@ def generate_video(
|
|
97 |
torch.manual_seed(seed)
|
98 |
|
99 |
# Read the content of the video file and encode it to base64
|
100 |
-
with open(video_path, "rb") as video_file:
|
101 |
-
|
102 |
|
103 |
# Prepend the appropriate data URI header with MIME type
|
104 |
-
video_data_uri = 'data:video/mp4;base64,' + video_base64
|
105 |
|
106 |
# clean-up (otherwise there is a risk of "ghosting", eg. someone seeing the previous generated video",
|
107 |
# of one of the steps go wrong)
|
108 |
-
os.remove(video_path)
|
109 |
|
110 |
-
return video_data_uri
|
|
|
111 |
|
112 |
def resize_image(image, output_size=(1024, 576)):
|
113 |
# Calculate aspect ratios
|
@@ -142,26 +143,39 @@ def resize_image(image, output_size=(1024, 576)):
|
|
142 |
|
143 |
|
144 |
css = """
|
145 |
-
|
146 |
img, video {
|
147 |
max-height: 400px;
|
148 |
object-fit: contain;
|
149 |
}
|
|
|
|
|
|
|
|
|
150 |
"""
|
151 |
|
152 |
-
with gr.Blocks(css=css) as
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
generate_btn.click(
|
161 |
fn=generate_video,
|
162 |
inputs=[image, seed, motion_bucket_id, fps_id],
|
163 |
-
outputs=
|
164 |
api_name="run"
|
165 |
)
|
166 |
|
167 |
-
|
|
|
64 |
|
65 |
max_64_bit_int = 2**63 - 1
|
66 |
|
67 |
+
@spaces.GPU(enable_queue=True, duration=240)
|
68 |
def generate_video(
|
69 |
image: Image,
|
70 |
seed: int,
|
|
|
97 |
torch.manual_seed(seed)
|
98 |
|
99 |
# Read the content of the video file and encode it to base64
|
100 |
+
# with open(video_path, "rb") as video_file:
|
101 |
+
# video_base64 = base64.b64encode(video_file.read()).decode('utf-8')
|
102 |
|
103 |
# Prepend the appropriate data URI header with MIME type
|
104 |
+
# video_data_uri = 'data:video/mp4;base64,' + video_base64
|
105 |
|
106 |
# clean-up (otherwise there is a risk of "ghosting", eg. someone seeing the previous generated video",
|
107 |
# of one of the steps go wrong)
|
108 |
+
# os.remove(video_path)
|
109 |
|
110 |
+
# return video_data_uri
|
111 |
+
return video_path
|
112 |
|
113 |
def resize_image(image, output_size=(1024, 576)):
|
114 |
# Calculate aspect ratios
|
|
|
143 |
|
144 |
|
145 |
css = """
|
|
|
146 |
img, video {
|
147 |
max-height: 400px;
|
148 |
object-fit: contain;
|
149 |
}
|
150 |
+
|
151 |
+
video {
|
152 |
+
margin: 0 auto
|
153 |
+
}
|
154 |
"""
|
155 |
|
156 |
+
with gr.Blocks(css=css) as SVD_XT_1_1:
|
157 |
+
with gr.Row():
|
158 |
+
with gr.Column():
|
159 |
+
image = gr.Image(label="Upload your image", type="pil")
|
160 |
+
generate_btn = gr.Button("Generate")
|
161 |
+
# base64_out = gr.Textbox(label="Base64 Video")
|
162 |
+
seed = gr.Slider(label="Seed", value=42, randomize=False, minimum=0, maximum=max_64_bit_int, step=1)
|
163 |
+
motion_bucket_id = gr.Slider(label="Motion bucket id", info="Controls how much motion to add/remove from the image", value=127, minimum=1, maximum=255)
|
164 |
+
fps_id = gr.Slider(label="Frames per second", info="The length of your video in seconds will be 25/fps", value=6, minimum=5, maximum=30)
|
165 |
+
|
166 |
+
with gr.Column():
|
167 |
+
video_out = gr.Video(
|
168 |
+
autoplay=True,
|
169 |
+
# height=512,
|
170 |
+
# width=512,
|
171 |
+
# elem_id="video_output"
|
172 |
+
)
|
173 |
|
174 |
generate_btn.click(
|
175 |
fn=generate_video,
|
176 |
inputs=[image, seed, motion_bucket_id, fps_id],
|
177 |
+
outputs=video_out,
|
178 |
api_name="run"
|
179 |
)
|
180 |
|
181 |
+
SVD_XT_1_1.launch()
|