@@ -467,6 +467,13 @@ def create_parser() -> argparse.ArgumentParser:
467
467
default = "mse" ,
468
468
help = "metric trained against (default: %(default)s)" ,
469
469
)
470
+ parent_parser .add_argument (
471
+ "-d" ,
472
+ "--output_directory" ,
473
+ type = str ,
474
+ default = "" ,
475
+ help = "path of output directory. Optional, required for output json file, results per video." ,
476
+ )
470
477
parent_parser .add_argument (
471
478
"-o" ,
472
479
"--output-file" ,
@@ -506,7 +513,7 @@ def create_parser() -> argparse.ArgumentParser:
506
513
return parser
507
514
508
515
509
- def main (args : Any = None ) -> None :
516
+ def main (args : Any = None ) -> None : # noqa: C901
510
517
if args is None :
511
518
args = sys .argv [1 :]
512
519
parser = create_parser ()
@@ -525,8 +532,8 @@ def main(args: Any = None) -> None:
525
532
raise SystemExit (1 )
526
533
527
534
# create output directory
528
- outputdir = args .output
529
- Path (outputdir ).mkdir (parents = True , exist_ok = True )
535
+ if args .output_directory :
536
+ Path (args . output_directory ).mkdir (parents = True , exist_ok = True )
530
537
531
538
if args .source == "pretrained" :
532
539
args .qualities = [int (q ) for q in args .qualities .split ("," ) if q ]
@@ -561,7 +568,7 @@ def main(args: Any = None) -> None:
561
568
filepaths ,
562
569
args .dataset ,
563
570
model ,
564
- outputdir ,
571
+ args . output_directory ,
565
572
trained_net = trained_net ,
566
573
description = description ,
567
574
** args_dict ,
@@ -581,7 +588,9 @@ def main(args: Any = None) -> None:
581
588
else :
582
589
output_file = args .output_file
583
590
584
- with (Path (f"{ outputdir } /{ output_file } " ).with_suffix (".json" )).open ("wb" ) as f :
591
+ with (Path (f"{ args .output_directory } /{ output_file } " ).with_suffix (".json" )).open (
592
+ "wb"
593
+ ) as f :
585
594
f .write (json .dumps (output , indent = 2 ).encode ())
586
595
print (json .dumps (output , indent = 2 ))
587
596
0 commit comments