MCPcopy Create free account
hub / github.com/Picsart-AI-Research/Text2Video-Zero / process_controlnet_pose

Method process_controlnet_pose

model.py:261–321  ·  view source on GitHub ↗
(self,
                                video_path,
                                prompt,
                                chunk_size=8,
                                watermark='Picsart AI Research',
                                merging_ratio=0.0,
                                num_inference_steps=20,
                                controlnet_conditioning_scale=1.0,
                                guidance_scale=9.0,
                                seed=42,
                                eta=0.0,
                                resolution=512,
                                use_cf_attn=True,
                                save_path=None)

Source from the content-addressed store, hash-verified

259 return utils.create_video(result, fps, path=save_path, watermark=gradio_utils.logo_name_to_path(watermark))
260
261 def process_controlnet_pose(self,
262 video_path,
263 prompt,
264 chunk_size=8,
265 watermark='Picsart AI Research',
266 merging_ratio=0.0,
267 num_inference_steps=20,
268 controlnet_conditioning_scale=1.0,
269 guidance_scale=9.0,
270 seed=42,
271 eta=0.0,
272 resolution=512,
273 use_cf_attn=True,
274 save_path=None):
275 print("Module Pose")
276 video_path = gradio_utils.motion_to_video_path(video_path)
277 if self.model_type != ModelType.ControlNetPose:
278 controlnet = ControlNetModel.from_pretrained(
279 "fusing/stable-diffusion-v1-5-controlnet-openpose")
280 self.set_model(ModelType.ControlNetPose,
281 model_id="runwayml/stable-diffusion-v1-5", controlnet=controlnet)
282 self.pipe.scheduler = DDIMScheduler.from_config(
283 self.pipe.scheduler.config)
284 if use_cf_attn:
285 self.pipe.unet.set_attn_processor(
286 processor=self.controlnet_attn_proc)
287 self.pipe.controlnet.set_attn_processor(
288 processor=self.controlnet_attn_proc)
289
290 video_path = gradio_utils.motion_to_video_path(
291 video_path) if 'Motion' in video_path else video_path
292
293 added_prompt = 'best quality, extremely detailed, HD, ultra-realistic, 8K, HQ, masterpiece, trending on artstation, art, smooth'
294 negative_prompts = 'longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer difits, cropped, worst quality, low quality, deformed body, bloated, ugly, unrealistic'
295
296 video, fps = utils.prepare_video(
297 video_path, resolution, self.device, self.dtype, False, output_fps=4)
298 control = utils.pre_process_pose(
299 video, apply_pose_detect=False).to(self.device).to(self.dtype)
300 f, _, h, w = video.shape
301 self.generator.manual_seed(seed)
302 latents = torch.randn((1, 4, h//8, w//8), dtype=self.dtype,
303 device=self.device, generator=self.generator)
304 latents = latents.repeat(f, 1, 1, 1)
305 result = self.inference(image=control,
306 prompt=prompt + ', ' + added_prompt,
307 height=h,
308 width=w,
309 negative_prompt=negative_prompts,
310 num_inference_steps=num_inference_steps,
311 guidance_scale=guidance_scale,
312 controlnet_conditioning_scale=controlnet_conditioning_scale,
313 eta=eta,
314 latents=latents,
315 seed=seed,
316 output_type='numpy',
317 split_to_chunks=True,
318 chunk_size=chunk_size,

Callers

nothing calls this directly

Calls 2

set_modelMethod · 0.95
inferenceMethod · 0.95

Tested by

no test coverage detected