Skip to content

Adding option for output directory in litpose predict #372

@ElTinmar

Description

@ElTinmar

Hi !

Would it be possible to add an argument to the cli to specify an output folder for the predictions? I am running the same model in parallel on several datasets on a computing clusters, and all the predictions end up in the same folder.

Something along the lines of:

    predict_parser.add_argument(
        "--prediction_dir",
        type=Path,
        help="directory where predictions will be saved\n"
    )
    def handle(args):
    """Handle the predict command."""
    # Delay this import because it's slow.
    from lightning_pose.api.model import Model

    model = Model.from_dir2(args.model_dir, hydra_overrides=args.overrides)
    
    # monkey-patching model to store prediction in a specific folder
    if args.prediction_dir is not None:
        model.video_preds_dir = lambda: Path(args.prediction_dir)
        model.labeled_videos_dir = lambda: Path(args.prediction_dir) / 'labeled_videos'
    
    input_paths = [Path(p) for p in args.input_path]

    if model.config.is_multi_view():
        _predict_multi_type_multi_view(
            model, input_paths, args.skip_viz, not args.overwrite, progress_file=args.progress_file
        )
    else:
        for p in input_paths:
            _predict_multi_type(
                model, p, args.skip_viz, not args.overwrite, progress_file=args.progress_file
            )

Thanks a lot for this great piece of software!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions