Skip to content

Commit 5fc7856

Browse files
authored
convert : fix remote option in Windows (#14100)
1 parent faed5a5 commit 5fc7856

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

convert_hf_to_gguf.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6389,8 +6389,8 @@ def parse_args() -> argparse.Namespace:
63896389
help="model is executed on big endian machine",
63906390
)
63916391
parser.add_argument(
6392-
"model", type=Path,
6393-
help="directory containing model file",
6392+
"model", type=str,
6393+
help="directory containing model file or huggingface repository ID (if --remote)",
63946394
nargs="?",
63956395
)
63966396
parser.add_argument(
@@ -6493,18 +6493,20 @@ def main() -> None:
64936493
else:
64946494
logging.basicConfig(level=logging.INFO)
64956495

6496-
dir_model = args.model
6497-
64986496
if args.remote:
6497+
hf_repo_id = args.model
64996498
from huggingface_hub import snapshot_download
65006499
local_dir = snapshot_download(
6501-
repo_id=str(dir_model),
6500+
repo_id=hf_repo_id,
65026501
allow_patterns=["LICENSE", "*.json", "*.md", "*.txt", "tokenizer.model"])
65036502
dir_model = Path(local_dir)
65046503
logger.info(f"Downloaded config and tokenizer to {local_dir}")
6504+
else:
6505+
hf_repo_id = None
6506+
dir_model = Path(args.model)
65056507

65066508
if not dir_model.is_dir():
6507-
logger.error(f'Error: {args.model} is not a directory')
6509+
logger.error(f'Error: {dir_model} is not a directory')
65086510
sys.exit(1)
65096511

65106512
ftype_map: dict[str, gguf.LlamaFileType] = {
@@ -6524,9 +6526,9 @@ def main() -> None:
65246526

65256527
if args.outfile is not None:
65266528
fname_out = args.outfile
6527-
elif args.remote:
6529+
elif hf_repo_id:
65286530
# if remote, use the model ID as the output file name
6529-
fname_out = Path("./" + str(args.model).replace("/", "-") + "-{ftype}.gguf")
6531+
fname_out = Path("./" + hf_repo_id.replace("/", "-") + "-{ftype}.gguf")
65306532
else:
65316533
fname_out = dir_model
65326534

@@ -6555,7 +6557,7 @@ def main() -> None:
65556557
split_max_tensors=args.split_max_tensors,
65566558
split_max_size=split_str_to_n_bytes(args.split_max_size), dry_run=args.dry_run,
65576559
small_first_shard=args.no_tensor_first_split,
6558-
remote_hf_model_id=str(args.model) if args.remote else None)
6560+
remote_hf_model_id=hf_repo_id)
65596561

65606562
if args.vocab_only:
65616563
logger.info("Exporting model vocab...")

0 commit comments

Comments
 (0)