Spaces:
Runtime error
Runtime error
Update worker_runpod.py
Browse files- worker_runpod.py +12 -12
worker_runpod.py
CHANGED
@@ -25,7 +25,7 @@ tokenxf = os.getenv("HF_API_TOKEN")
|
|
25 |
# Low GPU memory mode
|
26 |
low_gpu_memory_mode = False
|
27 |
lora_path = "/content/shirtlift.safetensors"
|
28 |
-
|
29 |
def to_pil(image):
|
30 |
if isinstance(image, Image.Image):
|
31 |
return image
|
@@ -75,13 +75,13 @@ with torch.inference_mode():
|
|
75 |
model_id = "/runpod-volume/model"
|
76 |
transformer = CogVideoXTransformer3DModel.from_pretrained_2d(
|
77 |
model_id, subfolder="transformer"
|
78 |
-
).to(
|
79 |
|
80 |
vae = AutoencoderKLCogVideoX.from_pretrained(
|
81 |
model_id, subfolder="vae"
|
82 |
-
).to(
|
83 |
|
84 |
-
text_encoder = T5EncoderModel.from_pretrained(model_id, subfolder="text_encoder")
|
85 |
|
86 |
sampler_dict = {
|
87 |
"Euler": EulerDiscreteScheduler,
|
@@ -102,7 +102,7 @@ with torch.inference_mode():
|
|
102 |
text_encoder=text_encoder,
|
103 |
transformer=transformer,
|
104 |
scheduler=scheduler,
|
105 |
-
torch_dtype=
|
106 |
)
|
107 |
else:
|
108 |
pipeline = CogVideoX_Fun_Pipeline.from_pretrained(
|
@@ -111,16 +111,16 @@ with torch.inference_mode():
|
|
111 |
text_encoder=text_encoder,
|
112 |
transformer=transformer,
|
113 |
scheduler=scheduler,
|
114 |
-
torch_dtype=
|
115 |
)
|
116 |
|
117 |
pipeline = merge_lora(pipeline, lora_path, 1.00)
|
118 |
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
|
125 |
|
126 |
|
@@ -130,13 +130,13 @@ def generate(input):
|
|
130 |
prompt = values["prompt"]
|
131 |
print("starting Generate function")
|
132 |
print(prompt)
|
133 |
-
negative_prompt = values.get("negative_prompt", "blurry, blurred, blurry face")
|
134 |
guidance_scale = values.get("guidance_scale", 6.0)
|
135 |
seed = values.get("seed", 42)
|
136 |
num_inference_steps = values.get("num_inference_steps", 18)
|
137 |
base_resolution = values.get("base_resolution", 512)
|
138 |
|
139 |
-
video_length = values.get("video_length",
|
140 |
fps = values.get("fps", 10)
|
141 |
|
142 |
save_path = "samples"
|
|
|
25 |
# Low GPU memory mode
|
26 |
low_gpu_memory_mode = False
|
27 |
lora_path = "/content/shirtlift.safetensors"
|
28 |
+
weight_dtype = torch.bfloat16
|
29 |
def to_pil(image):
|
30 |
if isinstance(image, Image.Image):
|
31 |
return image
|
|
|
75 |
model_id = "/runpod-volume/model"
|
76 |
transformer = CogVideoXTransformer3DModel.from_pretrained_2d(
|
77 |
model_id, subfolder="transformer"
|
78 |
+
).to(weight_dtype)
|
79 |
|
80 |
vae = AutoencoderKLCogVideoX.from_pretrained(
|
81 |
model_id, subfolder="vae"
|
82 |
+
).to(weight_dtype)
|
83 |
|
84 |
+
text_encoder = T5EncoderModel.from_pretrained(model_id, subfolder="text_encoder", torch_dtype=weight_dtype)
|
85 |
|
86 |
sampler_dict = {
|
87 |
"Euler": EulerDiscreteScheduler,
|
|
|
102 |
text_encoder=text_encoder,
|
103 |
transformer=transformer,
|
104 |
scheduler=scheduler,
|
105 |
+
torch_dtype=weight_dtype
|
106 |
)
|
107 |
else:
|
108 |
pipeline = CogVideoX_Fun_Pipeline.from_pretrained(
|
|
|
111 |
text_encoder=text_encoder,
|
112 |
transformer=transformer,
|
113 |
scheduler=scheduler,
|
114 |
+
torch_dtype=weight_dtype
|
115 |
)
|
116 |
|
117 |
pipeline = merge_lora(pipeline, lora_path, 1.00)
|
118 |
|
119 |
|
120 |
+
if low_gpu_memory_mode:
|
121 |
+
pipeline.enable_sequential_cpu_offload()
|
122 |
+
else:
|
123 |
+
pipeline.enable_model_cpu_offload()
|
124 |
|
125 |
|
126 |
|
|
|
130 |
prompt = values["prompt"]
|
131 |
print("starting Generate function")
|
132 |
print(prompt)
|
133 |
+
negative_prompt = values.get("negative_prompt", "The video is not of a high quality, it has a low resolution. Watermark present in each frame. Strange motion trajectory. blurry, blurred, grainy, distortion, blurry face")
|
134 |
guidance_scale = values.get("guidance_scale", 6.0)
|
135 |
seed = values.get("seed", 42)
|
136 |
num_inference_steps = values.get("num_inference_steps", 18)
|
137 |
base_resolution = values.get("base_resolution", 512)
|
138 |
|
139 |
+
video_length = values.get("video_length", 49)
|
140 |
fps = values.get("fps", 10)
|
141 |
|
142 |
save_path = "samples"
|