Skip to content

Commit 5d195f1

Browse files
GalunidCISC
andauthored
convert : handle mmproj filename/path properly (ggml-org#16760)
* convert: handle mmproj model output filename properly * remove redundant commits * Add model_type to gguf utility * Use mmproj- prefix instead of suffix * Apply CISC suggestion Co-authored-by: Sigbjørn Skjæret <[email protected]> --------- Co-authored-by: Sigbjørn Skjæret <[email protected]>
1 parent 226f295 commit 5d195f1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

convert_hf_to_gguf.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,17 @@ def get_audio_config(self) -> dict[str, Any] | None:
14971497
def set_type(self):
14981498
self.gguf_writer.add_type(gguf.GGUFType.MMPROJ)
14991499

1500+
def prepare_metadata(self, vocab_only: bool):
1501+
super().prepare_metadata(vocab_only=vocab_only)
1502+
1503+
output_type: str = self.ftype.name.partition("_")[2]
1504+
1505+
if self.fname_out.is_dir():
1506+
fname_default: str = gguf.naming_convention(self.metadata.name, self.metadata.basename, self.metadata.finetune, self.metadata.version, size_label=None, output_type=output_type, model_type=None)
1507+
self.fname_out = self.fname_out / f"mmproj-{fname_default}.gguf"
1508+
else:
1509+
self.fname_out = self.fname_out.parent / gguf.fill_templated_filename(self.fname_out.name, output_type)
1510+
15001511
def set_gguf_parameters(self):
15011512
self.gguf_writer.add_file_type(self.ftype)
15021513

@@ -9729,10 +9740,6 @@ def main() -> None:
97299740

97309741
logger.info(f"Loading model: {dir_model.name}")
97319742

9732-
if args.mmproj:
9733-
if "mmproj" not in fname_out.name:
9734-
fname_out = ModelBase.add_prefix_to_filename(fname_out, "mmproj-")
9735-
97369743
is_mistral_format = args.mistral_format
97379744
if is_mistral_format and not _mistral_common_installed:
97389745
raise ImportError(_mistral_import_error_msg)

0 commit comments

Comments
 (0)