Skip to content

Commit 144a976

Browse files
committed
Add support for video directory in CLI
1 parent 7532f75 commit 144a976

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

kineo/demo/offline/demo.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from kineo.io.audio_loader import VideoAudioLoader
1919
import argparse
2020
from omegaconf import OmegaConf
21+
import os
2122

2223
torch.backends.cuda.matmul.allow_tf32 = True
2324
torch.backends.cudnn.allow_tf32 = True
@@ -71,6 +72,22 @@ def main(config_file: str, sequence_name: str, video_paths: list[str], batch_siz
7172
gt_annotations={}
7273
)
7374

75+
76+
def expand_video_inputs(paths: list[str]) -> list[str]:
77+
"""Expand a single directory into a list of video files."""
78+
if len(paths) == 1 and os.path.isdir(paths[0]):
79+
root = paths[0]
80+
exts = {".mp4", ".mov", ".avi", ".mkv"}
81+
files = [
82+
os.path.join(root, f)
83+
for f in sorted(os.listdir(root))
84+
if os.path.splitext(f)[1].lower() in exts
85+
]
86+
if not files:
87+
raise ValueError(f"No video files found in directory: {root}")
88+
return files
89+
return paths
90+
7491
def cli():
7592
parser = argparse.ArgumentParser()
7693
parser.add_argument("--config-file", type=str, default="configs/demo/offline/nlf_single_person_sam2.yaml")
@@ -82,6 +99,8 @@ def cli():
8299
parser.add_argument("video_paths", type=str, nargs="+")
83100
args = parser.parse_args()
84101

102+
args.video_paths = expand_video_inputs(args.video_paths)
103+
85104
main(
86105
args.config_file,
87106
args.sequence_name,

0 commit comments

Comments
 (0)