当前位置:   article > 正文

kinetics数据集路径txt生成_wbiqb

wbiqb

目录结构:

  • > kinetics_400_val_RGB
    • >labels1_dir
      • > video_name1_dir
        • >frames1.jpg
        • >frames2.jpg
    • > labels2_dir
      • > video_name2_dir
        • > frames``
# gen_list.py
import os
import datetime
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('path', type=str, help='data_path of videos, absolute path')
parser.add_argument('outfile', type=str, help='output.txt file')
args = parser.parse_args()

start_time = datetime.datetime.now()
# get label dictionary 
labels = [ i for i in os.listdir(args.path)]
labels.sort()
if '.DS_Store' in labels:
    labels.remove('.DS_Store')
dic = {label:idx for (idx, label) in enumerate(labels)}


# get [video_path, num_of_frames, labels] 
tt = 0
dirss = [i for i in os.listdir(args.path)]
dirss.sort()
# print(dirss)

record = []
dic_cor = 0
for dirs in dirss[:]:
    if dirs == '.DS_Store':
        continue
    print(dic_cor)
    dic_cor += 1
    frames_path = []
    for video in os.listdir(os.path.join(args.path, dirs)):
        if video == '.DS_Store':
            continue
        # print(os.path.join(args.path, dirs, video))
        frames_path = [i for i in os.listdir(os.path.join(args.path, dirs, video))]
        frames_len = len(frames_path) - 2 if ".DS_Store" in frames_path else len(frames_path)-1
        # print(dirs, video) 
        record.append([os.path.join(args.path, dirs, video), frames_len, dic[dirs]])
        tt += 1
        if tt % 10000 == 0:
            print('record:', tt)
            with open(args.outfile,"a") as f:
                for i in range(len(record)):
                    rec =  str(record[i][0] + ' ' + str(record[i][1]) + ' ' + str(record[i][2]) + '\n')
                    f.write(rec)
                record = []

with open(args.outfile,"a") as f:
    for i in range(len(record)):
        rec =  str(record[i][0] + ' ' + str(record[i][1]) + ' ' + str(record[i][2]) + '\n')
        f.write(rec)

print("Run time:", datetime.datetime.now()-start_time)
  • 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
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55

How to use:

python gen_list.py /data/kinetics_400_val_RGB/ ./k400_val_rgb.txt
  • 1

output:

# video_path, frame_nums, label_id
/data/kinetics_400_val_RGB/barbequing/08csZOkVKCc_000027_000037 299 14
/data/kinetics_400_val_RGB/barbequing/WbIQbwSRJ0E_000099_000109 299 14
/data/kinetics_400_val_RGB/barbequing/n5bKEGvBr5Y_000018_000028 186 14
/data/kinetics_400_val_RGB/barbequing/OCnU5etEne4_000043_000053 298 14
/data/kinetics_400_val_RGB/barbequing/eP988Z8aD94_000063_000073 299 14
/data/kinetics_400_val_RGB/vault/AfETt6_Du1I_000022_000032 299 376
/data/kinetics_400_val_RGB/vault/ildJRtNCeHo_000006_000016 180 376
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

update:

目前不在做了,现有西部数据企业盘4TB 装着 Kinetics 400的数据集 的,转给有缘人。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/272047
推荐阅读
相关标签
  

闽ICP备14008679号