Skip to content

Commit

Permalink
fix pyright errors
Browse files Browse the repository at this point in the history
  • Loading branch information
danbev committed Jan 1, 2025
1 parent cddf732 commit ccf45bc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions convert_hf_to_gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def match_model_tensor_name(self, name: str, key: gguf.MODEL_TENSOR, bid: int |

def map_tensor_name(self, name: str, try_suffixes: Sequence[str] = (".weight", ".bias")) -> str:
new_name = self.tensor_map.get_name(key=name, try_suffixes=try_suffixes)
new_name_vision = None
if hasattr(self, 'v_tensor_map') and self.v_tensor_map is not None:
new_name_vision = self.v_tensor_map.get_name(key=name, try_suffixes=try_suffixes)
if new_name is not None:
Expand Down Expand Up @@ -1962,8 +1963,7 @@ class MLlamaModel(Model):
model_arch = gguf.MODEL_ARCH.MLLAMA

def __init__(self, *args, **kwargs):
from transformers import AutoTokenizer
self.dir_model = args[0] if args else kwargs.get('dir_model')
self.dir_model = Path(args[0]) if args else Path(kwargs.get('dir_model', '.'))
hparams = Model.load_hparams(self.dir_model)
#tokenizer = AutoTokenizer.from_pretrained(self.dir_model)
#vocab_size = len(tokenizer.vocab)
Expand Down Expand Up @@ -2030,8 +2030,11 @@ def set_gguf_parameters(self):
max_pos_embd = (self.vision_config["image_size"] // self.vision_config["patch_size"])**2 + 1
self.gguf_writer.add_vision_clip_max_position_embeddings(max_pos_embd)
self.gguf_writer.add_vision_supported_aspect_ratios(self.vision_config["supported_aspect_ratios"])
self.gguf_writer.add_vision_clip_image_mean(self.preprocessor_config["image_mean"])
self.gguf_writer.add_vision_clip_image_std(self.preprocessor_config["image_std"])
if self.preprocessor_config is not None:
self.gguf_writer.add_vision_clip_image_mean(self.preprocessor_config["image_mean"])
self.gguf_writer.add_vision_clip_image_std(self.preprocessor_config["image_std"])
else:
raise ValueError("preprocessor_config is None, cannot access 'image_mean' or 'image_std'")
self.gguf_writer.add_vision_clip_projection_dimension(self.vision_config["vision_output_dim"])

def modify_tensors(self, data_torch: Tensor, name: str, bid: int | None) -> Iterable[tuple[str, Tensor]]:
Expand Down

0 comments on commit ccf45bc

Please sign in to comment.