OmPrakashSingh1704 commited on
Commit
ad2ab39
1 Parent(s): af4a9f2
options/Video.py CHANGED
@@ -1,4 +1,4 @@
1
  from .Video_model import Model
2
 
3
  def Video(image):
4
- return Model.Video(image)
 
1
  from .Video_model import Model
2
 
3
  def Video(image):
4
+ return Model.Video(image)[0]
options/Video_model/Model.py CHANGED
@@ -53,8 +53,9 @@ def Video(
53
  base_count = len(glob(os.path.join(output_folder, "*.mp4")))
54
  video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
55
 
56
- # Only use autocast if on CUDA, otherwise run without it on CPU
57
  if device == "cuda":
 
58
  with torch.autocast(device_type='cuda', dtype=torch.float16):
59
  frames = pipeline(
60
  image, height=height, width=width,
@@ -67,20 +68,21 @@ def Video(
67
  generator=generator,
68
  ).frames[0]
69
  else:
70
- # No autocast for CPU since it doesn't support float32 in autocast
71
- frames = pipeline(
72
- image, height=height, width=width,
73
- num_inference_steps=num_inference_steps,
74
- min_guidance_scale=min_guidance_scale,
75
- max_guidance_scale=max_guidance_scale,
76
- num_frames=num_frames, fps=fps, motion_bucket_id=motion_bucket_id,
77
- decode_chunk_size=8,
78
- noise_aug_strength=0.02,
79
- generator=generator,
80
- ).frames[0]
 
81
 
82
  # Save the generated video
83
  save_video(frames, video_path, fps=fps, quality=5.0)
84
  torch.manual_seed(seed)
85
 
86
- return video_path, seed
 
53
  base_count = len(glob(os.path.join(output_folder, "*.mp4")))
54
  video_path = os.path.join(output_folder, f"{base_count:06d}.mp4")
55
 
56
+ # Perform computation with appropriate dtype based on device
57
  if device == "cuda":
58
+ # Use float16 for GPU
59
  with torch.autocast(device_type='cuda', dtype=torch.float16):
60
  frames = pipeline(
61
  image, height=height, width=width,
 
68
  generator=generator,
69
  ).frames[0]
70
  else:
71
+ # Use float32 for CPU to avoid issues with half precision
72
+ with torch.autocast(device_type='cpu', dtype=torch.float32):
73
+ frames = pipeline(
74
+ image, height=height, width=width,
75
+ num_inference_steps=num_inference_steps,
76
+ min_guidance_scale=min_guidance_scale,
77
+ max_guidance_scale=max_guidance_scale,
78
+ num_frames=num_frames, fps=fps, motion_bucket_id=motion_bucket_id,
79
+ decode_chunk_size=8,
80
+ noise_aug_strength=0.02,
81
+ generator=generator,
82
+ ).frames[0]
83
 
84
  # Save the generated video
85
  save_video(frames, video_path, fps=fps, quality=5.0)
86
  torch.manual_seed(seed)
87
 
88
+ return video_path, seed
options/Video_model/__pycache__/Model.cpython-310.pyc CHANGED
Binary files a/options/Video_model/__pycache__/Model.cpython-310.pyc and b/options/Video_model/__pycache__/Model.cpython-310.pyc differ