Tensorflow 2.0 视频分类(二) UCF-101数据集预处理


关于UCF-101介绍请参看:
https://blog.csdn.net/Forrest97/article/details/105938520

UCF-101数据下载

视频下载路径:http://crcv.ucf.edu/data/UCF101/UCF101.rar
解压后就是分类数据集的标准目录格式,二级目录名为人类活动类别,二级目录下就是对应的视频数据。每个视频长度为4s,大小320*240, 帧率25HZ。
需要注意: 相同的活动下,有不同的视频是截取自同一个长视频的片段,即视频中的人物和背景等特征基本相似,因此为避免此类视频被分别划分到train和test集合引起训练效果不合实际的过大,UCF放提供了标准的train和test集合检索文件。
集合划分检索文件下载地址:
https://www.crcv.ucf.edu/data/UCF101/UCF101TrainTestSplits-RecognitionTask.zip
解压后如下,有三组推荐的划分方案
在这里插入图片描述

建立Train 和 Test 数据集合目录

运行代码1_move_files.py
将解压后的UCF-101和ucfTrainTestlist放在相同目录下运行以下代码,完成对原有视频的重新划分和移动

import os
import os.path

def get_train_test_lists(version='01'):
    """
    Using one of the train/test files (01, 02, or 03), get the filename
    breakdowns we'll later use to move everything.
    选择一个数据分割版本,并读取检索路径
    """
    # Get our files based on version. 
    test_file = os.path.join('ucfTrainTestlist', 'testlist' + version + '.txt')
    train_file = os.path.join('ucfTrainTestlist', 'trainlist' + version + '.txt')

    # Build the test list.
    with open(test_file) as fin:
        test_list = [row.strip() for row in list(fin)]

    # Build the train list. Extra step to remove the class index.
    with open(train_file) as fin:
        train_list = [row.strip() for row in list(fin)]
        train_list = [row.split(' ')[0] for row in train_list]

    # Set the groups in a dictionary.
    file_groups = {
   
        'train': train_list,
        
  • 5
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 12
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值