|
import json |
|
import argparse |
|
import os |
|
import cv2 |
|
from tqdm import tqdm |
|
from concurrent.futures import ThreadPoolExecutor, as_completed |
|
from read_annotation import read_json_file, process_record |
|
|
|
|
|
|
|
def main(): |
|
parser = argparse.ArgumentParser() |
|
parser.add_argument('--vidstg', type=str, default='VidSTG-Dataset/annotations/train_annotations.json') |
|
parser.add_argument('--vidor_anno_path_base', type=str, default='vidor/train_annotation/training/') |
|
parser.add_argument('--vidor_path_base', type=str, default='vidor/train/video') |
|
parser.add_argument('--output', type=str, default='results_multithread.json') |
|
args = parser.parse_args() |
|
|
|
|
|
vidor_anno_path_base = args.vidor_anno_path_base |
|
vidor_path_base = args.vidor_path_base |
|
|
|
vidstg_data = read_json_file(args.vidstg) |
|
|
|
all_results = [] |
|
|
|
|
|
with ThreadPoolExecutor(max_workers=6) as executor: |
|
|
|
progress = tqdm(total=len(vidstg_data)) |
|
|
|
|
|
futures = [executor.submit(process_record, record, vidor_anno_path_base, vidor_path_base) for index, record in enumerate(vidstg_data)] |
|
|
|
for future in as_completed(futures): |
|
all_results.extend(future.result()) |
|
progress.update(1) |
|
|
|
with open(args.output, 'w') as json_file: |
|
json.dump(all_results, json_file) |
|
|
|
|
|
if __name__ == "__main__": |
|
main() |
|
|
|
|
|
|
|
|