MCPcopy Create free account
hub / github.com/cubiq/ComfyUI_InstantID / load_model

Method load_model

InstantID.py:147–169  ·  view source on GitHub ↗
(self, instantid_file)

Source from the content-addressed store, hash-verified

145 CATEGORY = "InstantID"
146
147 def load_model(self, instantid_file):
148 ckpt_path = folder_paths.get_full_path("instantid", instantid_file)
149
150 model = comfy.utils.load_torch_file(ckpt_path, safe_load=True)
151
152 if ckpt_path.lower().endswith(".safetensors"):
153 st_model = {"image_proj": {}, "ip_adapter": {}}
154 for key in model.keys():
155 if key.startswith("image_proj."):
156 st_model["image_proj"][key.replace("image_proj.", "")] = model[key]
157 elif key.startswith("ip_adapter."):
158 st_model["ip_adapter"][key.replace("ip_adapter.", "")] = model[key]
159 model = st_model
160
161 model = InstantID(
162 model,
163 cross_attention_dim=1280,
164 output_cross_attention_dim=model["ip_adapter"]["1.to_k_ip.weight"].shape[1],
165 clip_embeddings_dim=512,
166 clip_extra_context_tokens=16,
167 )
168
169 return (model,)
170
171def extractFeatures(insightface, image, extract_kps=False):
172 face_img = tensor_to_image(image)

Callers

nothing calls this directly

Calls 1

InstantIDClass · 0.85

Tested by

no test coverage detected