Spaces:
Runtime error
Runtime error
Update motionclone/utils/util.py
Browse files- motionclone/utils/util.py +12 -0
motionclone/utils/util.py
CHANGED
|
@@ -215,6 +215,8 @@ def load_weights(
|
|
| 215 |
return animation_pipeline
|
| 216 |
|
| 217 |
def video_preprocess(video_path, height, width, video_length, duration=None, sample_start_idx=0,):
|
|
|
|
|
|
|
| 218 |
|
| 219 |
video_name = video_path.split('/')[-1].split('.')[0]
|
| 220 |
vr = decord.VideoReader(video_path)
|
|
@@ -230,6 +232,16 @@ def video_preprocess(video_path, height, width, video_length, duration=None, sam
|
|
| 230 |
sample_index = np.linspace(0, total_frames - 1, video_length, dtype=int)
|
| 231 |
print(total_frames,sample_index)
|
| 232 |
video = vr.get_batch(sample_index)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
video = rearrange(video, "f h w c -> f c h w")
|
| 234 |
|
| 235 |
video = F.interpolate(video, size=(height, width), mode="bilinear", align_corners=True)
|
|
|
|
| 215 |
return animation_pipeline
|
| 216 |
|
| 217 |
def video_preprocess(video_path, height, width, video_length, duration=None, sample_start_idx=0,):
|
| 218 |
+
#print("in video_preprocess:")
|
| 219 |
+
#print(video_path, height, width, video_length, duration, sample_start_idx)
|
| 220 |
|
| 221 |
video_name = video_path.split('/')[-1].split('.')[0]
|
| 222 |
vr = decord.VideoReader(video_path)
|
|
|
|
| 232 |
sample_index = np.linspace(0, total_frames - 1, video_length, dtype=int)
|
| 233 |
print(total_frames,sample_index)
|
| 234 |
video = vr.get_batch(sample_index)
|
| 235 |
+
|
| 236 |
+
'''
|
| 237 |
+
print("after betch :")
|
| 238 |
+
print(video)
|
| 239 |
+
'''
|
| 240 |
+
import torch
|
| 241 |
+
if hasattr(video, "asnumpy"):
|
| 242 |
+
video = video.asnumpy()
|
| 243 |
+
video = torch.from_numpy(video)
|
| 244 |
+
|
| 245 |
video = rearrange(video, "f h w c -> f c h w")
|
| 246 |
|
| 247 |
video = F.interpolate(video, size=(height, width), mode="bilinear", align_corners=True)
|