@@ -6389,8 +6389,8 @@ def parse_args() -> argparse.Namespace:
6389
6389
help = "model is executed on big endian machine" ,
6390
6390
)
6391
6391
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) " ,
6394
6394
nargs = "?" ,
6395
6395
)
6396
6396
parser .add_argument (
@@ -6493,18 +6493,20 @@ def main() -> None:
6493
6493
else :
6494
6494
logging .basicConfig (level = logging .INFO )
6495
6495
6496
- dir_model = args .model
6497
-
6498
6496
if args .remote :
6497
+ hf_repo_id = args .model
6499
6498
from huggingface_hub import snapshot_download
6500
6499
local_dir = snapshot_download (
6501
- repo_id = str ( dir_model ) ,
6500
+ repo_id = hf_repo_id ,
6502
6501
allow_patterns = ["LICENSE" , "*.json" , "*.md" , "*.txt" , "tokenizer.model" ])
6503
6502
dir_model = Path (local_dir )
6504
6503
logger .info (f"Downloaded config and tokenizer to { local_dir } " )
6504
+ else :
6505
+ hf_repo_id = None
6506
+ dir_model = Path (args .model )
6505
6507
6506
6508
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' )
6508
6510
sys .exit (1 )
6509
6511
6510
6512
ftype_map : dict [str , gguf .LlamaFileType ] = {
@@ -6524,9 +6526,9 @@ def main() -> None:
6524
6526
6525
6527
if args .outfile is not None :
6526
6528
fname_out = args .outfile
6527
- elif args . remote :
6529
+ elif hf_repo_id :
6528
6530
# 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" )
6530
6532
else :
6531
6533
fname_out = dir_model
6532
6534
@@ -6555,7 +6557,7 @@ def main() -> None:
6555
6557
split_max_tensors = args .split_max_tensors ,
6556
6558
split_max_size = split_str_to_n_bytes (args .split_max_size ), dry_run = args .dry_run ,
6557
6559
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 )
6559
6561
6560
6562
if args .vocab_only :
6561
6563
logger .info ("Exporting model vocab..." )
0 commit comments