我是靠谱客的博主 风趣大白,最近开发中收集的这篇文章主要介绍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, ' 1n'])
        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

 

最后

以上就是风趣大白为你收集整理的ILSVRC2015 制作 ImageSets 的 txt 文本信息 MEGA数据集的全部内容,希望文章能够帮你解决ILSVRC2015 制作 ImageSets 的 txt 文本信息 MEGA数据集所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(37)

评论列表共有 0 条评论

立即
投稿
返回
顶部