Spaces:
Build error
Build error
Clean up
Browse files70 unmodified lines7172737475767778798081828384858687888990919270 unmodified linesself.model_names = LIGHTWEIGHT_MODEL_NAMESself.weight_root = LIGHTWEIGHT_WEIGHT_ROOTbase_model_url = 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors'self.download_base_model(base_model_url)base_model_path = self.model_dir / base_model_url.split('/')[-1]self.load_base_model(base_model_path)else:self.model_names = ORIGINAL_MODEL_NAMESself.weight_root = ORIGINAL_WEIGHT_ROOTself.download_models()def download_base_model(self, base_model_url: str) -> None:model_name = base_model_url.split('/')[-1]out_path = self.model_dir / model_nameif out_path.exists():returnsubprocess.run(shlex.split(f'wget {base_model_url} -O {out_path}'))def load_base_model(self, model_path: pathlib.Path) -> None:self.model.load_state_dict(load_state_dict(model_path,location=self.device.type),strict=False)70 unmodified lines71727374757677787980818283848586878889909170 unmodified linesself.model_names = LIGHTWEIGHT_MODEL_NAMESself.weight_root = LIGHTWEIGHT_WEIGHT_ROOTbase_model_url = 'https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors'self.load_base_model(base_model_url)else:self.model_names = ORIGINAL_MODEL_NAMESself.weight_root = ORIGINAL_WEIGHT_ROOTself.download_models()def download_base_model(self, model_url: str) -> pathlib.Path:model_name = model_url.split('/')[-1]out_path = self.model_dir / model_nameif not out_path.exists():subprocess.run(shlex.split(f'wget {model_url} -O {out_path}'))return out_pathdef load_base_model(self, model_url: str) -> None:model_path = self.download_base_model(model_url)self.model.load_state_dict(load_state_dict(model_path,location=self.device.type),strict=False)
model.py+8-9