Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/python/pose_format/bin/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging
from tqdm import tqdm
from tqdm.contrib.concurrent import process_map
import psutil
import os
from functools import partial

Expand Down Expand Up @@ -84,8 +83,7 @@ def get_corresponding_pose_path(video_path: Path, keep_video_suffixes: bool = Fa


def process_video(keep_video_suffixes: bool, pose_format: str, additional_config: dict, vid_path: Path) -> bool:
cpu_num = psutil.cpu_num() if hasattr(psutil, "cpu_num") else (
os.sched_getcpu()) if hasattr(os, 'sched_getcpu') else "N/A"
cpu_num = os.sched_getcpu() if hasattr(os, 'sched_getcpu') else "N/A"
print(f'Estimating {vid_path} on CPU {cpu_num}')

try:
Expand Down Expand Up @@ -179,7 +177,8 @@ def main():
if args.num_workers == 1:
print('Process sequentially ...')
else:
print(f'Multiprocessing with {args.num_workers} workers on {len(os.sched_getaffinity(0))} available CPUs ...')
available_cpus = len(os.sched_getaffinity(0)) if hasattr(os, 'sched_getaffinity') else os.cpu_count()
print(f'Multiprocessing with {args.num_workers} workers on {available_cpus} available CPUs ...')

func = partial(process_video, args.keep_video_suffixes, args.format, additional_config)
for success in process_map(func, videos_with_missing_pose_files, max_workers=args.num_workers):
Expand Down
Loading