Handle vision tokens in ming
This commit is contained in:
1 parent
77847d7ff8
commit
460c29ba9c
1 file changed
+4
-4
@@ -310,8 +310,8 @@ class MingImageTextEncoder(nn.Module, OstrisTransformersMixin):
|
|||||||
out = {}
|
out = {}
|
||||||
banks = {}
|
banks = {}
|
||||||
for key, value in state_dict.items():
|
for key, value in state_dict.items():
|
||||||
if key == "tokenizer_json": # the tokenizer comes from the vendor repo
|
if key == "tokenizer_json" or key.startswith("thinker.lm_head."):
|
||||||
continue
|
continue # tokenizer comes from the vendor repo; no lm head here
|
||||||
if not key.startswith("thinker."):
|
if not key.startswith("thinker."):
|
||||||
out[key] = value
|
out[key] = value
|
||||||
continue
|
continue
|
||||||
@@ -355,8 +355,8 @@ class MingImageTextEncoder(nn.Module, OstrisTransformersMixin):
|
|||||||
):
|
):
|
||||||
state_dict = cls.convert_state_dict_on_load(state_dict)
|
state_dict = cls.convert_state_dict_on_load(state_dict)
|
||||||
if not any(k.startswith("vision.") for k in state_dict):
|
if not any(k.startswith("vision.") for k in state_dict):
|
||||||
# the ComfyUI repack carries no vision tower (its PR is text to
|
# a repack without the vision tower (the first uploads); editing
|
||||||
# image so far); editing needs one, so it comes from the vendor repo
|
# needs one, so it comes from the vendor repo
|
||||||
state_dict = dict(state_dict)
|
state_dict = dict(state_dict)
|
||||||
state_dict.update(cls.read_vision_weights(config_path or cls.aitk_config_repo, dtype))
|
state_dict.update(cls.read_vision_weights(config_path or cls.aitk_config_repo, dtype))
|
||||||
return super().load_from_state_dict(
|
return super().load_from_state_dict(
|
||||||
|
|||||||
Reference in new issue
Block a user