From d43b1ef729970a3159249525109a706c7c0ebb72 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Sat, 4 May 2024 13:18:14 -0400 Subject: [PATCH 1/4] modified error message --- mlx_vlm/utils.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mlx_vlm/utils.py b/mlx_vlm/utils.py index c87b72b..69dddb9 100644 --- a/mlx_vlm/utils.py +++ b/mlx_vlm/utils.py @@ -6,6 +6,7 @@ import re import shutil import time +import textwrap from pathlib import Path from textwrap import dedent from typing import Any, Callable, Dict, Generator, Optional, Tuple, Union @@ -120,7 +121,20 @@ def load_model(model_path: Path, lazy: bool = False) -> nn.Module: weight_files = glob.glob(str(model_path / "*.safetensors")) if not weight_files: logging.error(f"No safetensors found in {model_path}") - raise FileNotFoundError(f"No safetensors found in {model_path}") + message = f""" +No safetensors found in {model_path} +Create safetensors using the following code: +from transformers import AutoModelForCausalLM, AutoProcessor + +model_id= "" +model = AutoModelForCausalLM.from_pretrained(model_id) +processor = AutoProcessor.from_pretrained(model_id) + +model.save_pretrained("") + +processor.save_pretrained("") + """ + raise FileNotFoundError(message) weights = {} for wf in weight_files: From b1c9c323ccf7e714390deda59cb5f47ae1da3156 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Sat, 4 May 2024 13:20:34 -0400 Subject: [PATCH 2/4] remove unused import --- mlx_vlm/utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mlx_vlm/utils.py b/mlx_vlm/utils.py index 69dddb9..7e3aa38 100644 --- a/mlx_vlm/utils.py +++ b/mlx_vlm/utils.py @@ -6,7 +6,6 @@ import re import shutil import time -import textwrap from pathlib import Path from textwrap import dedent from typing import Any, Callable, Dict, Generator, Optional, Tuple, Union From 1a49bea93f460d4029bb8db715f46ef88e9d21ec Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Sat, 4 May 2024 17:04:05 -0400 Subject: [PATCH 3/4] added more instructions and quoted code --- mlx_vlm/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mlx_vlm/utils.py b/mlx_vlm/utils.py index 7e3aa38..36b527f 100644 --- a/mlx_vlm/utils.py +++ b/mlx_vlm/utils.py @@ -123,15 +123,17 @@ def load_model(model_path: Path, lazy: bool = False) -> nn.Module: message = f""" No safetensors found in {model_path} Create safetensors using the following code: +``` from transformers import AutoModelForCausalLM, AutoProcessor model_id= "" model = AutoModelForCausalLM.from_pretrained(model_id) processor = AutoProcessor.from_pretrained(model_id) -model.save_pretrained("") - -processor.save_pretrained("") +model.save_pretrained("") +processor.save_pretrained("") +``` +Then use the as the --hf-path. """ raise FileNotFoundError(message) From a58542557e05db7b84c7e0031f86245e97906b50 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Sat, 4 May 2024 17:45:24 -0400 Subject: [PATCH 4/4] convert script sample --- mlx_vlm/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mlx_vlm/utils.py b/mlx_vlm/utils.py index 36b527f..1890e1b 100644 --- a/mlx_vlm/utils.py +++ b/mlx_vlm/utils.py @@ -133,7 +133,10 @@ def load_model(model_path: Path, lazy: bool = False) -> nn.Module: model.save_pretrained("") processor.save_pretrained("") ``` -Then use the as the --hf-path. +Then use the as the --hf-path in the convert script. +``` +python -m mlx_vlm.convert --hf-path --mlx-path +``` """ raise FileNotFoundError(message)