Spaces:
Runtime error
Runtime error
bugfix/Add default pipe
Browse files47 unmodified lines484950515253544 unmodified lines5960616263646514 unmodified lines80818283848586878889909192939449 unmodified lines14414514614714814915052 unmodified lines20320420520620720820958 unmodified lines26826927027127227327456 unmodified lines33133233333433533633737 unmodified lines37537637737837938038147 unmodified linesself.model_name = ""def set_model(self, model_type: ModelType, model_id: str, **kwargs):if self.pipe is not None:del self.pipetorch.cuda.empty_cache()gc.collect()4 unmodified linesself.model_name = model_iddef inference_chunk(self, frame_ids, **kwargs):if self.pipe is None:returnprompt = np.array(kwargs.pop('prompt'))14 unmodified lines**kwargs)def inference(self, split_to_chunks=False, chunk_size=8, **kwargs):if self.pipe is None:returntomesd.remove_patch(self.pipe)if "merging_ratio" in kwargs:merging_ratio = kwargs.pop("merging_ratio")if merging_ratio > 0:tomesd.apply_patch(self.pipe, ratio=merging_ratio)seed = kwargs.pop('seed', 0)if seed < 0:seed = self.generator.seed()49 unmodified linesresolution=512,use_cf_attn=True,save_path=None):print("Processing Canny")video_path = gradio_utils.edge_path_to_video_path(video_path)if self.model_type != ModelType.ControlNetCanny:controlnet = ControlNetModel.from_pretrained(52 unmodified linesresolution=512,use_cf_attn=True,save_path=None):print("Processing Pose")video_path = gradio_utils.motion_to_video_path(video_path)if self.model_type != ModelType.ControlNetPose:controlnet = ControlNetModel.from_pretrained(58 unmodified linesresolution=512,use_cf_attn=True,save_path=None):print("Processing Canny_DB")db_path = gradio_utils.get_model_from_db_selection(db_path)video_path = gradio_utils.get_video_from_canny_selection(video_path)# Load db and controlnet weights56 unmodified linesmerging_ratio=0.0,use_cf_attn=True,save_path=None,):print("Processing Pix2Pix")if self.model_type != ModelType.Pix2Pix_Video:self.set_model(ModelType.Pix2Pix_Video,model_id="timbrooks/instruct-pix2pix")37 unmodified linessmooth_bg=False,smooth_bg_strength=0.4,path=None):print("Processing Text2Video")if self.model_type != ModelType.Text2Video or model_name != self.model_name:print("Model update")unet = UNet2DConditionModel.from_pretrained(47 unmodified lines484950515253544 unmodified lines5960616263646514 unmodified lines808182838485868788899091929349 unmodified lines14314414514614714814952 unmodified lines20220320420520620720858 unmodified lines26726826927027127227356 unmodified lines33033133233333433533637 unmodified lines37437537637737837938047 unmodified linesself.model_name = ""def set_model(self, model_type: ModelType, model_id: str, **kwargs):if hasattr(self, "pipe") and self.pipe is not None:del self.pipetorch.cuda.empty_cache()gc.collect()4 unmodified linesself.model_name = model_iddef inference_chunk(self, frame_ids, **kwargs):if not hasattr(self, "pipe") or self.pipe is None:returnprompt = np.array(kwargs.pop('prompt'))14 unmodified lines**kwargs)def inference(self, split_to_chunks=False, chunk_size=8, **kwargs):if not hasattr(self, "pipe") or self.pipe is None:returnif "merging_ratio" in kwargs:merging_ratio = kwargs.pop("merging_ratio")# if merging_ratio > 0:tomesd.apply_patch(self.pipe, ratio=merging_ratio)seed = kwargs.pop('seed', 0)if seed < 0:seed = self.generator.seed()49 unmodified linesresolution=512,use_cf_attn=True,save_path=None):print("Module Canny")video_path = gradio_utils.edge_path_to_video_path(video_path)if self.model_type != ModelType.ControlNetCanny:controlnet = ControlNetModel.from_pretrained(52 unmodified linesresolution=512,use_cf_attn=True,save_path=None):print("Module Pose")video_path = gradio_utils.motion_to_video_path(video_path)if self.model_type != ModelType.ControlNetPose:controlnet = ControlNetModel.from_pretrained(58 unmodified linesresolution=512,use_cf_attn=True,save_path=None):print("Module Canny_DB")db_path = gradio_utils.get_model_from_db_selection(db_path)video_path = gradio_utils.get_video_from_canny_selection(video_path)# Load db and controlnet weights56 unmodified linesmerging_ratio=0.0,use_cf_attn=True,save_path=None,):print("Module Pix2Pix")if self.model_type != ModelType.Pix2Pix_Video:self.set_model(ModelType.Pix2Pix_Video,model_id="timbrooks/instruct-pix2pix")37 unmodified linessmooth_bg=False,smooth_bg_strength=0.4,path=None):print("Module Text2Video")if self.model_type != ModelType.Text2Video or model_name != self.model_name:print("Model update")unet = UNet2DConditionModel.from_pretrained(
model.py+11-12