IITheLordII commited on
Commit
b9a0e22
·
verified ·
1 Parent(s): 8336ddb

Update diffusers_helper/utils.py

Browse files
Files changed (1) hide show
  1. diffusers_helper/utils.py +3 -3
diffusers_helper/utils.py CHANGED
@@ -263,7 +263,7 @@ def soft_append_bcthw(history, current, overlap=0):
263
  return output.to(history)
264
 
265
 
266
- def save_bcthw_as_mp4(x, output_filename, fps=10):
267
  b, c, t, h, w = x.shape
268
 
269
  per_row = b
@@ -276,7 +276,7 @@ def save_bcthw_as_mp4(x, output_filename, fps=10):
276
  x = torch.clamp(x.float(), -1., 1.) * 127.5 + 127.5
277
  x = x.detach().cpu().to(torch.uint8)
278
  x = einops.rearrange(x, '(m n) c t h w -> t (m h) (n w) c', n=per_row)
279
- torchvision.io.write_video(output_filename, x, fps=fps, video_codec='libx264', options={'crf': '0'})
280
  return x
281
 
282
 
@@ -610,4 +610,4 @@ def move_optimizer_to_device(optimizer, device):
610
  for state in optimizer.state.values():
611
  for k, v in state.items():
612
  if isinstance(v, torch.Tensor):
613
- state[k] = v.to(device)
 
263
  return output.to(history)
264
 
265
 
266
+ def save_bcthw_as_mp4(x, output_filename, fps=10, crf=0):
267
  b, c, t, h, w = x.shape
268
 
269
  per_row = b
 
276
  x = torch.clamp(x.float(), -1., 1.) * 127.5 + 127.5
277
  x = x.detach().cpu().to(torch.uint8)
278
  x = einops.rearrange(x, '(m n) c t h w -> t (m h) (n w) c', n=per_row)
279
+ torchvision.io.write_video(output_filename, x, fps=fps, video_codec='libx264', options={'crf': str(int(crf))})
280
  return x
281
 
282
 
 
610
  for state in optimizer.state.values():
611
  for k, v in state.items():
612
  if isinstance(v, torch.Tensor):
613
+ state[k] = v.to(device)