MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / from_pretrained

Method from_pretrained

diffsynth/models/omnigen.py:364–378  ·  view source on GitHub ↗
(cls, model_name)

Source from the content-addressed store, hash-verified

362
363 @classmethod
364 def from_pretrained(cls, model_name):
365 if not os.path.exists(model_name):
366 cache_folder = os.getenv('HF_HUB_CACHE')
367 model_name = snapshot_download(repo_id=model_name,
368 cache_dir=cache_folder,
369 ignore_patterns=['flax_model.msgpack', 'rust_model.ot', 'tf_model.h5'])
370 config = Phi3Config.from_pretrained(model_name)
371 model = cls(config)
372 if os.path.exists(os.path.join(model_name, 'model.safetensors')):
373 print("Loading safetensors")
374 ckpt = load_file(os.path.join(model_name, 'model.safetensors'))
375 else:
376 ckpt = torch.load(os.path.join(model_name, 'model.pt'), map_location='cpu')
377 model.load_state_dict(ckpt)
378 return model
379
380 def initialize_weights(self):
381 assert not hasattr(self, "llama")

Callers

nothing calls this directly

Calls 1

loadMethod · 0.45

Tested by

no test coverage detected