meepmoo commited on
Commit
93af8bd
·
verified ·
1 Parent(s): d82b5af

Update worker_runpod.py

Browse files
Files changed (1) hide show
  1. worker_runpod.py +36 -23
worker_runpod.py CHANGED
@@ -73,34 +73,48 @@ def download_image(url, download_dir="/content"):
73
  # downloaded_image_path = download_image(validation_image_start)
74
  with torch.inference_mode():
75
  model_id = "/runpod-volume/model"
76
- transformer = CogVideoXTransformer3DModel.from_pretrained_2d(model_id, subfolder="transformer").to(torch.bfloat16)
 
 
77
 
78
- vae = AutoencoderKLCogVideoX.from_pretrained(model_id, subfolder="vae").to(torch.bfloat16)
 
 
79
 
80
  text_encoder = T5EncoderModel.from_pretrained(model_id, subfolder="text_encoder")
 
81
  sampler_dict = {
82
- "Euler": EulerDiscreteScheduler,
83
- "Euler A": EulerAncestralDiscreteScheduler,
84
- "DPM++": DPMSolverMultistepScheduler,
85
- "PNDM": PNDMScheduler,
86
- "DDIM_Cog": CogVideoXDDIMScheduler,
87
- "DDIM_Origin": DDIMScheduler,
88
  }
 
89
  scheduler = sampler_dict["DPM++"].from_pretrained(model_id, subfolder="scheduler")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
- # Pipeline setup
92
- if transformer.config.in_channels != vae.config.latent_channels:
93
- pipeline = CogVideoX_Fun_Pipeline_Inpaint.from_pretrained(
94
- model_id, vae=vae, text_encoder=text_encoder,
95
- transformer=transformer, scheduler=scheduler,
96
- torch_dtype=torch.bfloat16
97
- )
98
- else:
99
- pipeline = CogVideoX_Fun_Pipeline.from_pretrained(
100
- model_id, vae=vae, text_encoder=text_encoder,
101
- transformer=transformer, scheduler=scheduler,
102
- torch_dtype=torch.bfloat16
103
- )
104
 
105
  # if low_gpu_memory_mode:
106
  # pipeline.enable_sequential_cpu_offload()
@@ -120,8 +134,7 @@ def generate(input):
120
  seed = values.get("seed", 42)
121
  num_inference_steps = values.get("num_inference_steps", 18)
122
  base_resolution = values.get("base_resolution", 512)
123
- lora_weight = values.get("lora_weight", 1.00)
124
- pipeline = merge_lora(pipeline, lora_path, lora_weight)
125
  video_length = values.get("video_length", 53)
126
  fps = values.get("fps", 10)
127
 
 
73
  # downloaded_image_path = download_image(validation_image_start)
74
  with torch.inference_mode():
75
  model_id = "/runpod-volume/model"
76
+ transformer = CogVideoXTransformer3DModel.from_pretrained_2d(
77
+ model_id, subfolder="transformer"
78
+ ).to(torch.bfloat16)
79
 
80
+ vae = AutoencoderKLCogVideoX.from_pretrained(
81
+ model_id, subfolder="vae"
82
+ ).to(torch.bfloat16)
83
 
84
  text_encoder = T5EncoderModel.from_pretrained(model_id, subfolder="text_encoder")
85
+
86
  sampler_dict = {
87
+ "Euler": EulerDiscreteScheduler,
88
+ "Euler A": EulerAncestralDiscreteScheduler,
89
+ "DPM++": DPMSolverMultistepScheduler,
90
+ "PNDM": PNDMScheduler,
91
+ "DDIM_Cog": CogVideoXDDIMScheduler,
92
+ "DDIM_Origin": DDIMScheduler,
93
  }
94
+
95
  scheduler = sampler_dict["DPM++"].from_pretrained(model_id, subfolder="scheduler")
96
+ lora_weight = values.get("lora_weight", 1.00)
97
+ pipeline = merge_lora(pipeline, lora_path, lora_weight)
98
+
99
+ if transformer.config.in_channels != vae.config.latent_channels:
100
+ pipeline = CogVideoX_Fun_Pipeline_Inpaint.from_pretrained(
101
+ model_id,
102
+ vae=vae,
103
+ text_encoder=text_encoder,
104
+ transformer=transformer,
105
+ scheduler=scheduler,
106
+ torch_dtype=torch.bfloat16
107
+ )
108
+ else:
109
+ pipeline = CogVideoX_Fun_Pipeline.from_pretrained(
110
+ model_id,
111
+ vae=vae,
112
+ text_encoder=text_encoder,
113
+ transformer=transformer,
114
+ scheduler=scheduler,
115
+ torch_dtype=torch.bfloat16
116
+ )
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
  # if low_gpu_memory_mode:
120
  # pipeline.enable_sequential_cpu_offload()
 
134
  seed = values.get("seed", 42)
135
  num_inference_steps = values.get("num_inference_steps", 18)
136
  base_resolution = values.get("base_resolution", 512)
137
+
 
138
  video_length = values.get("video_length", 53)
139
  fps = values.get("fps", 10)
140