Skip to content

Commit 5da384b

Browse files
bartowski1182ngxson
authored andcommitted
llava : Allow locally downloaded models for QwenVL (ggml-org#10833)
* Allow locally downloaded models for QwenVL * Define model_path * rm trailing space --------- Co-authored-by: Xuan Son Nguyen <[email protected]>
1 parent aa7ccec commit 5da384b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/llava/qwen2_vl_surgery.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def main(args):
8888
else:
8989
raise ValueError()
9090

91+
local_model = False
92+
model_path = ""
9193
model_name = args.model_name
9294
print("model_name: ", model_name)
9395
qwen2vl = Qwen2VLForConditionalGeneration.from_pretrained(
@@ -97,8 +99,10 @@ def main(args):
9799
vcfg = cfg.vision_config
98100

99101
if os.path.isdir(model_name):
102+
local_model = True
100103
if model_name.endswith(os.sep):
101104
model_name = model_name[:-1]
105+
model_path = model_name
102106
model_name = os.path.basename(model_name)
103107
fname_out = f"{model_name.replace('/', '-').lower()}-vision.gguf"
104108

@@ -139,7 +143,10 @@ def main(args):
139143
it will be hardcoded in the `clip_image_build_graph` from `clip.cpp`.
140144
"""
141145

142-
processor: Qwen2VLProcessor = AutoProcessor.from_pretrained(model_name)
146+
if local_model:
147+
processor: Qwen2VLProcessor = AutoProcessor.from_pretrained(model_path)
148+
else:
149+
processor: Qwen2VLProcessor = AutoProcessor.from_pretrained(model_name)
143150
fout.add_array("clip.vision.image_mean", processor.image_processor.image_mean) # type: ignore[reportAttributeAccessIssue]
144151
fout.add_array("clip.vision.image_std", processor.image_processor.image_std) # type: ignore[reportAttributeAccessIssue]
145152

0 commit comments

Comments
 (0)