ILSVRC2015 制作 ImageSets 的 txt 文本信息 MEGA数据集

import os


# DET_train.txt
prestr = 'train/ILSVRC2015_VID_train_0000/'
rdPath = './Data/VID/train/ILSVRC2015_VID_train_0000/'
wtPath = './ImageSets/DET_train.txt'

dirList = os.listdir(rdPath)
with open(wtPath, 'a') as f:
    for na in dirList:
        wtstr = ''.join([prestr, na, ' 1\n'])
        f.write(wtstr)


# VID_train_15frames.txt
frameNum = 15
prestr = 'train/ILSVRC2015_VID_train_0000/'
rdPath = './Data/VID/train/ILSVRC2015_VID_train_0000/'
wtPath = './ImageSets/VID_train_15frames.txt'

dirList = os.listdir(rdPath)
with open(wtPath, 'a') as f:
    for na in dirList:
        head = ''.join([prestr, na, ' 1 '])

        childPath = "".join([rdPath, na, '/'])
        cnt = len(os.listdir(childPath))
        interval = cnt // frameNum
        start = cnt // 2 - (frameNum // 2) * interval
        tail = ''.join([' ', str(cnt), '\n'])
        for j in range(frameNum):
            frameID = start + j * interval
            wtstr = ''.join([head, str(frameID), tail])
            f.write(wtstr)


# VID_train_every10frames.txt
everyFrames = 10
prestr = 'train/ILSVRC2015_VID_train_0000/'
rdPath = './Data/VID/train/ILSVRC2015_VID_train_0000/'
wtPath = './ImageSets/VID_train_every10frames.txt'

dirList = os.listdir(rdPath)
with open(wtPath, 'a') as f:
    for na in dirList:
        head = ''.join([prestr, na, ' 1 '])

        childPath = "".join([rdPath, na, '/'])
        cnt = len(os.listdir(childPath))
        interval = everyFrames
        start = 0
        tail = ''.join([' ', str(cnt), '\n'])
        cycles = cnt // interval
        cycles = cycles + 1 if  cycles * interval < cnt else cycles
        for j in range(cycles):
            frameID = start + interval * j
            wtstr = ''.join([head, str(frameID), tail])
            f.write(wtstr)


# VID_val_frames.txt
start = 1
prestr = 'val/'
rdPath = './Data/VID/val/'
wtPath = './ImageSets/VID_val_videos.txt'

dirList = os.listdir(rdPath)
with open(wtPath, 'a') as f:
    for na in dirList:
        childPath = "".join([rdPath, na, '/'])
        cnt = len(os.listdir(childPath))

        tail = ''.join([' ', str(cnt), '\n'])
        for j in range(cnt):
            head = "".join([prestr, na, ' ', str(start), ' '])
            wtstr = ''.join([head, str(j), tail])
            f.write(wtstr)
            start = start + 1


# VID_val_videos.txt
start = 1
prestr = 'val/'
rdPath = './Data/VID/val/'
wtPath = './ImageSets/VID_val_frames.txt'

dirList = os.listdir(rdPath)
with open(wtPath, 'a') as f:
    for na in dirList:
        childPath = "".join([rdPath, na, '/'])
        cnt = len(os.listdir(childPath))
        head = "".join([prestr, na, '/'])

        for j in range(cnt):
            temp = "{:0>6d}".format(j)
            tail = ''.join([' ', str(start), '\n'])
            wtstr = ''.join([head, temp, tail])
            f.write(wtstr)
            start = start + 1

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值