Elffuss BraidHub

kikocis/mlx-vlm public

Merge pull request #15 from IamShubhamGupto/main

Better error message for non safetensor repository
Changesetdca02c491d0b2332f152dd953751fe42808f6c8473efbf4311312ebe16381ae4
AuthorPrince Canuma <prince.gdt@gmail.com> · 2024-05-05 00:26 +02:00
CommitterGitHub <noreply@github.com> · 2024-05-05 00:26 +02:00
Parentsb2ffb51dff21, 18a97ae8d33d

Browse the files at this changeset

1 file changed

modified mlx_vlm/utils.py +19 −1
@@ -120,7 +120,25 @@
120120 weight_files = glob.glob(str(model_path / "*.safetensors"))
121121 if not weight_files:
122122 logging.error(f"No safetensors found in {model_path}")
123- raise FileNotFoundError(f"No safetensors found in {model_path}")
123+ message = f"""
124+No safetensors found in {model_path}
125+Create safetensors using the following code:
126+```
127+from transformers import AutoModelForCausalLM, AutoProcessor
128+
129+model_id= "<huggingface_model_id>"
130+model = AutoModelForCausalLM.from_pretrained(model_id)
131+processor = AutoProcessor.from_pretrained(model_id)
132+
133+model.save_pretrained("<local_dir>")
134+processor.save_pretrained("<local_dir>")
135+```
136+Then use the <local_dir> as the --hf-path in the convert script.
137+```
138+python -m mlx_vlm.convert --hf-path <local_dir> --mlx-path <mlx_dir>
139+```
140+ """
141+ raise FileNotFoundError(message)
124142
125143 weights = {}
126144 for wf in weight_files: