@@ -79,10 +79,20 @@ def upload_model(args):
7979 rf = roboflow .Roboflow (args .api_key )
8080 workspace = rf .workspace (args .workspace )
8181
82- # Deploy to specific version
83- project = workspace .project (args .project )
84- version = project .version (args .version_number )
85- version .deploy (str (args .model_type ), str (args .model_path ), str (args .filename ))
82+ if args .version_number is not None :
83+ # Deploy to specific version
84+ project = workspace .project (args .project )
85+ version = project .version (args .version_number )
86+ version .deploy (str (args .model_type ), str (args .model_path ), str (args .filename ))
87+ else :
88+ # Deploy to multiple projects
89+ workspace .deploy_model (
90+ model_type = str (args .model_type ),
91+ model_path = str (args .model_path ),
92+ project_ids = args .project ,
93+ model_name = str (args .model_name ),
94+ filename = str (args .filename ),
95+ )
8696
8797
8898def list_projects (args ):
@@ -479,13 +489,15 @@ def _add_upload_model_parser(subparsers):
479489 upload_model_parser .add_argument (
480490 "-p" ,
481491 dest = "project" ,
482- help = "project_id to upload the model into" ,
492+ action = "append" , # Allow multiple projects
493+ help = "project_id to upload the model into (can be specified multiple times)" ,
483494 )
484495 upload_model_parser .add_argument (
485496 "-v" ,
486497 dest = "version_number" ,
487498 type = int ,
488- help = "version number to upload the model to" ,
499+ help = "version number to upload the model to (optional)" ,
500+ default = None ,
489501 )
490502 upload_model_parser .add_argument (
491503 "-t" ,
@@ -503,6 +515,11 @@ def _add_upload_model_parser(subparsers):
503515 default = "weights/best.pt" ,
504516 help = "name of the model file" ,
505517 )
518+ upload_model_parser .add_argument (
519+ "-n" ,
520+ dest = "model_name" ,
521+ help = "name of the model" ,
522+ )
506523 upload_model_parser .set_defaults (func = upload_model )
507524
508525
0 commit comments