File size: 1,223 Bytes
483de47 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# ------------------------------------------------------------------------
# Copyright (c) 2022 megvii-research. All Rights Reserved.
# ------------------------------------------------------------------------
from glob import glob
import json
from concurrent.futures import ThreadPoolExecutor
from threading import Lock
from tqdm import tqdm
det_db = {}
to_cache = []
for file in glob("/data/Dataset/mot/crowdhuman/train_image/*.txt"):
to_cache.append(file)
for file in glob("/data/Dataset/mot/DanceTrack/*/*/img1/*.txt"):
to_cache.append(file)
for file in glob("/data/Dataset/mot/MOT17/images/*/*/img1/*.txt"):
to_cache.append(file)
for file in glob("/data/Dataset/mot/MOT20/train/*/img1/*.txt"):
to_cache.append(file)
for file in glob("/data/Dataset/mot/HIE20/train/*/img1/*.txt"):
to_cache.append(file)
pbar = tqdm(total=len(to_cache))
mutex = Lock()
def cache(file):
with open(file) as f:
tmp = [l for l in f]
with mutex:
det_db[file] = tmp
pbar.update()
with ThreadPoolExecutor(max_workers=48) as exe:
for file in to_cache:
exe.submit(cache, file)
with open("/data/Dataset/mot/det_db_oc_sort_full.json", 'w') as f:
json.dump(det_db, f)
|