Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,9 +60,15 @@ def read_video(video) -> torch.Tensor:
|
|
| 60 |
"""
|
| 61 |
Reads a video file and converts it into a torch.Tensor with the shape [F, C, H, W].
|
| 62 |
"""
|
| 63 |
-
|
| 64 |
to_tensor_transform = transforms.ToTensor()
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
return video_tensor
|
| 67 |
|
| 68 |
def round_to_nearest_resolution_acceptable_by_vae(height, width, vae_temporal_compression_ratio):
|
|
@@ -199,7 +205,8 @@ def generate_video(
|
|
| 199 |
print("######## control_video ", control_video)
|
| 200 |
if control_video is not None:
|
| 201 |
# Use the pre-processed canny frames
|
| 202 |
-
processed_video = load_video(control_video)
|
|
|
|
| 203 |
print("$$$$$$$ control_video is not None ", control_video)
|
| 204 |
else:
|
| 205 |
print("$$$$$$$ control_video is None ", reference_video, width, height)
|
|
|
|
| 60 |
"""
|
| 61 |
Reads a video file and converts it into a torch.Tensor with the shape [F, C, H, W].
|
| 62 |
"""
|
| 63 |
+
video_tensor = []
|
| 64 |
to_tensor_transform = transforms.ToTensor()
|
| 65 |
+
if isinstance(video, str):
|
| 66 |
+
with imageio.get_reader(video) as reader:
|
| 67 |
+
# Read all frames
|
| 68 |
+
for frame in reader:
|
| 69 |
+
video_tensor.append(to_tensor_transform(frame))
|
| 70 |
+
else: # video is a list of pil images
|
| 71 |
+
video_tensor = torch.stack([to_tensor_transform(img) for img in video])
|
| 72 |
return video_tensor
|
| 73 |
|
| 74 |
def round_to_nearest_resolution_acceptable_by_vae(height, width, vae_temporal_compression_ratio):
|
|
|
|
| 205 |
print("######## control_video ", control_video)
|
| 206 |
if control_video is not None:
|
| 207 |
# Use the pre-processed canny frames
|
| 208 |
+
#processed_video = load_video(control_video)
|
| 209 |
+
processed_video = control_video
|
| 210 |
print("$$$$$$$ control_video is not None ", control_video)
|
| 211 |
else:
|
| 212 |
print("$$$$$$$ control_video is None ", reference_video, width, height)
|