Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -184,127 +184,127 @@ def generate_video(positive_prompt, num_frames, input_image):
|
|
184 |
print("Number of Frames:", num_frames)
|
185 |
print("Input Image:", input_image)
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
)
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
clip_name="google_t5-v1_1-xxl_encoderonly-fp8_e4m3fn.safetensors",
|
208 |
-
type="sd3",
|
209 |
-
device="default",
|
210 |
)
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
)
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
detect_gender_source="no",
|
274 |
-
input_faces_index="0",
|
275 |
-
source_faces_index="0",
|
276 |
-
console_log_level=1,
|
277 |
-
input_image=get_value_at_index(cogvideodecode_11, 0),
|
278 |
-
source_image=get_value_at_index(loadimage_8, 0),
|
279 |
-
)
|
280 |
-
|
281 |
-
cr_upscale_image_151 = cr_upscale_image.upscale(
|
282 |
-
upscale_model="4x_NMKD-Superscale-SP_178000_G.pth",
|
283 |
-
mode="rescale",
|
284 |
-
rescale_factor=4,
|
285 |
-
resize_width=720,
|
286 |
-
resampling_method="lanczos",
|
287 |
-
supersample="true",
|
288 |
-
rounding_modulus=16,
|
289 |
-
image=get_value_at_index(reactorfaceswap_3, 0),
|
290 |
-
)
|
291 |
-
|
292 |
-
vhs_videocombine_154 = vhs_videocombine.combine_video(
|
293 |
-
frame_rate=8,
|
294 |
-
loop_count=0,
|
295 |
-
filename_prefix="AnimateDiff",
|
296 |
-
format="video/h264-mp4",
|
297 |
-
pix_fmt="yuv420p",
|
298 |
-
crf=19,
|
299 |
-
save_metadata=True,
|
300 |
-
trim_to_audio=False,
|
301 |
-
pingpong=True,
|
302 |
-
save_output=True,
|
303 |
-
images=get_value_at_index(cr_upscale_image_151, 0),
|
304 |
-
unique_id=7214086815220268849,
|
305 |
-
)
|
306 |
-
saved_path = f"output/{vhs_videocombine_154['ui']['images'][0]['filename']}"
|
307 |
-
return saved_path
|
308 |
|
309 |
|
310 |
if __name__ == "__main__":
|
|
|
184 |
print("Number of Frames:", num_frames)
|
185 |
print("Input Image:", input_image)
|
186 |
|
187 |
+
progress = gr.Progress(track_tqdm=True)
|
188 |
+
import_custom_nodes()
|
189 |
+
with torch.inference_mode():
|
190 |
+
downloadandloadcogvideomodel = NODE_CLASS_MAPPINGS[
|
191 |
+
"DownloadAndLoadCogVideoModel"
|
192 |
+
]()
|
193 |
+
downloadandloadcogvideomodel_1 = downloadandloadcogvideomodel.loadmodel(
|
194 |
+
model="THUDM/CogVideoX-5b",
|
195 |
+
precision="bf16",
|
196 |
+
quantization="disabled",
|
197 |
+
enable_sequential_cpu_offload=True,
|
198 |
+
attention_mode="sdpa",
|
199 |
+
load_device="main_device",
|
200 |
+
)
|
201 |
+
|
202 |
+
loadimage = NODE_CLASS_MAPPINGS["LoadImage"]()
|
203 |
+
loadimage_8 = loadimage.load_image(image=input_image)
|
204 |
+
|
205 |
+
cliploader = NODE_CLASS_MAPPINGS["CLIPLoader"]()
|
206 |
+
cliploader_20 = cliploader.load_clip(
|
207 |
+
clip_name="google_t5-v1_1-xxl_encoderonly-fp8_e4m3fn.safetensors",
|
208 |
+
type="sd3",
|
209 |
+
device="default",
|
210 |
+
)
|
211 |
+
|
212 |
+
emptylatentimage = NODE_CLASS_MAPPINGS["EmptyLatentImage"]()
|
213 |
+
emptylatentimage_161 = emptylatentimage.generate(
|
214 |
+
width=360, #reduce this to avoid OOM error
|
215 |
+
height=240, #reduce this to avoid OOM error
|
216 |
+
batch_size=1 #reduce this to avoid OOM error
|
217 |
+
)
|
218 |
+
|
219 |
+
cogvideotextencode = NODE_CLASS_MAPPINGS["CogVideoTextEncode"]()
|
220 |
+
cogvideosampler = NODE_CLASS_MAPPINGS["CogVideoSampler"]()
|
221 |
+
cogvideodecode = NODE_CLASS_MAPPINGS["CogVideoDecode"]()
|
222 |
+
reactorfaceswap = NODE_CLASS_MAPPINGS["ReActorFaceSwap"]()
|
223 |
+
cr_upscale_image = NODE_CLASS_MAPPINGS["CR Upscale Image"]()
|
224 |
+
vhs_videocombine = NODE_CLASS_MAPPINGS["VHS_VideoCombine"]()
|
225 |
+
|
226 |
+
for q in range(1):
|
227 |
+
cogvideotextencode_30 = cogvideotextencode.process(
|
228 |
+
prompt=positive_prompt,
|
229 |
+
strength=1,
|
230 |
+
force_offload=True,
|
231 |
+
clip=get_value_at_index(cliploader_20, 0),
|
232 |
)
|
233 |
+
|
234 |
+
cogvideotextencode_31 = cogvideotextencode.process(
|
235 |
+
prompt='',
|
236 |
+
strength=1,
|
237 |
+
force_offload=True,
|
238 |
+
clip=get_value_at_index(cogvideotextencode_30, 1),
|
|
|
|
|
|
|
239 |
)
|
240 |
+
|
241 |
+
cogvideosampler_155 = cogvideosampler.process(
|
242 |
+
num_frames=num_frames,
|
243 |
+
steps=30, #reduce this to avoid OOM error
|
244 |
+
cfg=6,
|
245 |
+
seed=random.randint(1, 2**64),
|
246 |
+
scheduler="CogVideoXDDIM",
|
247 |
+
denoise_strength=1,
|
248 |
+
model=get_value_at_index(downloadandloadcogvideomodel_1, 0),
|
249 |
+
positive=get_value_at_index(cogvideotextencode_30, 0),
|
250 |
+
negative=get_value_at_index(cogvideotextencode_31, 0),
|
251 |
+
samples=get_value_at_index(emptylatentimage_161, 0),
|
252 |
)
|
253 |
+
|
254 |
+
cogvideodecode_11 = cogvideodecode.decode(
|
255 |
+
enable_vae_tiling=False,
|
256 |
+
tile_sample_min_height=240,#reduce this to avoid OOM error
|
257 |
+
tile_sample_min_width=360,#reduce this to avoid OOM error
|
258 |
+
tile_overlap_factor_height=0.2,
|
259 |
+
tile_overlap_factor_width=0.2,
|
260 |
+
auto_tile_size=True,
|
261 |
+
vae=get_value_at_index(downloadandloadcogvideomodel_1, 1),
|
262 |
+
samples=get_value_at_index(cogvideosampler_155, 0),
|
263 |
+
)
|
264 |
+
|
265 |
+
reactorfaceswap_3 = reactorfaceswap.execute(
|
266 |
+
enabled=True,
|
267 |
+
swap_model="inswapper_128.onnx",
|
268 |
+
facedetection="retinaface_resnet50",
|
269 |
+
face_restore_model="GFPGANv1.4.pth",
|
270 |
+
face_restore_visibility=1,
|
271 |
+
codeformer_weight=0.75,
|
272 |
+
detect_gender_input="no",
|
273 |
+
detect_gender_source="no",
|
274 |
+
input_faces_index="0",
|
275 |
+
source_faces_index="0",
|
276 |
+
console_log_level=1,
|
277 |
+
input_image=get_value_at_index(cogvideodecode_11, 0),
|
278 |
+
source_image=get_value_at_index(loadimage_8, 0),
|
279 |
+
)
|
280 |
+
|
281 |
+
cr_upscale_image_151 = cr_upscale_image.upscale(
|
282 |
+
upscale_model="4x_NMKD-Superscale-SP_178000_G.pth",
|
283 |
+
mode="rescale",
|
284 |
+
rescale_factor=4,
|
285 |
+
resize_width=720,
|
286 |
+
resampling_method="lanczos",
|
287 |
+
supersample="true",
|
288 |
+
rounding_modulus=16,
|
289 |
+
image=get_value_at_index(reactorfaceswap_3, 0),
|
290 |
+
)
|
291 |
+
|
292 |
+
vhs_videocombine_154 = vhs_videocombine.combine_video(
|
293 |
+
frame_rate=8,
|
294 |
+
loop_count=0,
|
295 |
+
filename_prefix="AnimateDiff",
|
296 |
+
format="video/h264-mp4",
|
297 |
+
pix_fmt="yuv420p",
|
298 |
+
crf=19,
|
299 |
+
save_metadata=True,
|
300 |
+
trim_to_audio=False,
|
301 |
+
pingpong=True,
|
302 |
+
save_output=True,
|
303 |
+
images=get_value_at_index(cr_upscale_image_151, 0),
|
304 |
+
unique_id=7214086815220268849,
|
305 |
+
)
|
306 |
+
saved_path = f"output/{vhs_videocombine_154['ui']['images'][0]['filename']}"
|
307 |
+
return saved_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
|
309 |
|
310 |
if __name__ == "__main__":
|