NTU RGB+D数据集 训练集、测试集划分与缺失值处理

NTU RGB+D数据集的基本信息不再赘述,如有需要请移步:NTU-RGB+D数据集,本文着眼于其训练集、测试集的划分与缺失值处理(附代码)。

训练集、测试集划分

Cross-Subject

  • 按照人物ID***(P)***进行划分,其中将人物ID为1,2,4,5,8,9,13,14,15,16,17,18,19,25,27,28,31,34,35,38的样本作为训练集(20人),共40320个样本;剩余的作为测试集(20人),共16560个样本。
import os
import shutil


path = "./NTU RGB+D"      # 文件夹目录,存放所有56880个样本的文件夹
files = os.listdir(path)    # 得到文件夹下的所有文件名称
train = ['P001', 'P002', 'P004', 'P005', 'P008', 'P009', 'P013', 'P014', 'P015', 'P016', 'P017', 'P018', 'P019',
         'P025', 'P027', 'P028', 'P031', 'P034', 'P035', 'P038']
test = ['P003', 'P006', 'P007', 'P010', 'P011', 'P012', 'P020', 'P021', 'P022', 'P023', 'P024', 'P026', 'P029',
        'P030', 'P032', 'P033', 'P036', 'P037', 'P039', 'P040']

for file in files:  # 遍历文件夹
    for i in range(20):
        if train[i] in file:
            file = os.path.join(path, file)
            shutil.copy(file, './Cross-Subject/Train')
    for i in range(20):
        if test[i] in file:
            file = os.path.join(path, file)
            shutil.copy(file, './Cross-Subject/Test')

Cross-View

  • 按照相机ID***(C)***进行划分,其中将相机ID为2,3的作为训练集(2个相机),共37920个样本;相机ID为1的作为测试集,共18960个样本。
import os
import shutil


path = "./NTU RGB+D"      # 文件夹目录,存放所有56880个样本的文件夹
files = os.listdir(path)    # 得到文件夹下的所有文件名称
train = ['C002', 'C003']
test = ['C001']

for file in files:  # 遍历文件夹
    for i in range(2):
        if train[i] in file:
            file = os.path.join(path, file)
            shutil.copy(file, './Cross-View/Train')
    for i in range(1):
        if test[i] in file:
            file = os.path.join(path, file)
            shutil.copy(file, './Cross-View/Test')

缺失值处理

  • NTU RGB+D数据集的部分数据***(共302个样本)***存在骨架缺失问题,该部分数据官方建议弃用。

缺失样本名称如下:

S001C002P005R002A008
S001C002P006R001A008
S001C003P002R001A055
S001C003P002R002A012
S001C003P005R002A004
S001C003P005R002A005
S001C003P005R002A006
S001C003P006R002A008
S002C002P011R002A030
S002C003P008R001A020
S002C003P010R002A010
S002C003P011R002A007
S002C003P011R002A011
S002C003P014R002A007
S003C001P019R001A055
S003C002P002R002A055
S003C002P018R002A055
S003C003P002R001A055
S003C003P016R001A055
S003C003P018R002A024
S004C002P003R001A013
S004C002P008R001A009
S004C002P020R001A003
S004C002P020R001A004
S004C002P020R001A012
S004C002P020R001A020
S004C002P020R001A021
S004C002P020R001A036
S005C002P004R001A001
S005C002P004R001A003
S005C002P010R001A016
S005C002P010R001A017
S005C002P010R001A048
S005C002P010R001A049
S005C002P016R001A009
S005C002P016R001A010
S005C002P018R001A003
S005C002P018R001A028
S005C002P018R001A029
S005C003P016R002A009
S005C003P018R002A013
S005C003P021R002A057
S006C001P001R002A055
S006C002P007R001A005
S006C002P007R001A006
S006C002P016R001A043
S006C002P016R001A051
S006C002P016R001A052
S006C002P022R001A012
S006C002P023R001A020
S006C002P023R001A021
S006C002P023R001A022
S006C002P023R001A023
S006C002P024R001A018
S006C002P024R001A019
S006C003P001R002A013
S006C003P007R002A009
S006C003P007R002A010
S006C003P007R002A025
S006C003P016R001A060
S006C003P017R001A055
S006C003P017R002A013
S006C003P017R002A014
S006C003P017R002A015
S006C003P022R002A013
S007C001P018R002A050
S007C001P025R002A051
S007C001P028R001A050
S007C001P028R001A051
S007C001P028R001A052
S007C002P008R002A008
S007C002P015R002A055
S007C002P026R001A008
S007C002P026R001A009
S007C002P026R001A010
S007C002P026R001A011
S007C002P026R001A012
S007C002P026R001A050
S007C002P027R001A011
S007C002P027R001A013
S007C002P028R002A055
S007C003P007R001A002
S007C003P007R001A004
S007C003P019R001A060
S007C003P027R002A001
S007C003P027R002A002
S007C003P027R002A003
S007C003P027R002A004
S007C003P027R002A005
S007C003P027R002A006
S007C003P027R002A007
S007C003P027R002A008
S007C003P027R002A009
S007C003P027R002A010
S007C003P027R002A011
S007C003P027R002A012
S007C003P027R002A013
S008C002P001R001A009
S008C002P001R001A010
S008C002P001R001A014
S008C002P001R001A015
S008C002P001R001A016
S008C002P001R001A018
S008C002P001R001A019
S008C002P008R002A059
S008C002P025R001A060
S008C002P029R001A004
S008C002P031R001A005
S008C002P031R001A006
S008C002P032R001A018
S008C002P034R001A018
S008C002P034R001A019
S008C002P035R001A059
S008C002P035R002A002
S008C002P035R002A005
S008C003P007R001A009
S008C003P007R001A016
S008C003P007R001A017
S008C003P007R001A018
S008C003P007R001A019
S008C003P007R001A020
S008C003P007R001A021
S008C003P007R001A022
S008C003P007R001A023
S008C003P007R001A025
S008C003P007R001A026
S008C003P007R001A028
S008C003P007R001A029
S008C003P007R002A003
S008C003P008R002A050
S008C003P025R002A002
S008C003P025R002A011
S008C003P025R002A012
S008C003P025R002A016
S008C003P025R002A020
S008C003P025R002A022
S008C003P025R002A023
S008C003P025R002A030
S008C003P025R002A031
S008C003P025R002A032
S008C003P025R002A033
S008C003P025R002A049
S008C003P025R002A060
S008C003P031R001A001
S008C003P031R002A004
S008C003P031R002A014
S008C003P031R002A015
S008C003P031R002A016
S008C003P031R002A017
S008C003P032R002A013
S008C003P033R002A001
S008C003P033R002A011
S008C003P033R002A012
S008C003P034R002A001
S008C003P034R002A012
S008C003P034R002A022
S008C003P034R002A023
S008C003P034R002A024
S008C003P034R002A044
S008C003P034R002A045
S008C003P035R002A016
S008C003P035R002A017
S008C003P035R002A018
S008C003P035R002A019
S008C003P035R002A020
S008C003P035R002A021
S009C002P007R001A001
S009C002P007R001A003
S009C002P007R001A014
S009C002P008R001A014
S009C002P015R002A050
S009C002P016R001A002
S009C002P017R001A028
S009C002P017R001A029
S009C003P017R002A030
S009C003P025R002A054
S010C001P007R002A020
S010C002P016R002A055
S010C002P017R001A005
S010C002P017R001A018
S010C002P017R001A019
S010C002P019R001A001
S010C002P025R001A012
S010C003P007R002A043
S010C003P008R002A003
S010C003P016R001A055
S010C003P017R002A055
S011C001P002R001A008
S011C001P018R002A050
S011C002P008R002A059
S011C002P016R002A055
S011C002P017R001A020
S011C002P017R001A021
S011C002P018R002A055
S011C002P027R001A009
S011C002P027R001A010
S011C002P027R001A037
S011C003P001R001A055
S011C003P002R001A055
S011C003P008R002A012
S011C003P015R001A055
S011C003P016R001A055
S011C003P019R001A055
S011C003P025R001A055
S011C003P028R002A055
S012C001P019R001A060
S012C001P019R002A060
S012C002P015R001A055
S012C002P017R002A012
S012C002P025R001A060
S012C003P008R001A057
S012C003P015R001A055
S012C003P015R002A055
S012C003P016R001A055
S012C003P017R002A055
S012C003P018R001A055
S012C003P018R001A057
S012C003P019R002A011
S012C003P019R002A012
S012C003P025R001A055
S012C003P027R001A055
S012C003P027R002A009
S012C003P028R001A035
S012C003P028R002A055
S013C001P015R001A054
S013C001P017R002A054
S013C001P018R001A016
S013C001P028R001A040
S013C002P015R001A054
S013C002P017R002A054
S013C002P028R001A040
S013C003P008R002A059
S013C003P015R001A054
S013C003P017R002A054
S013C003P025R002A022
S013C003P027R001A055
S013C003P028R001A040
S014C001P027R002A040
S014C002P015R001A003
S014C002P019R001A029
S014C002P025R002A059
S014C002P027R002A040
S014C002P039R001A050
S014C003P007R002A059
S014C003P015R002A055
S014C003P019R002A055
S014C003P025R001A048
S014C003P027R002A040
S015C001P008R002A040
S015C001P016R001A055
S015C001P017R001A055
S015C001P017R002A055
S015C002P007R001A059
S015C002P008R001A003
S015C002P008R001A004
S015C002P008R002A040
S015C002P015R001A002
S015C002P016R001A001
S015C002P016R002A055
S015C003P008R002A007
S015C003P008R002A011
S015C003P008R002A012
S015C003P008R002A028
S015C003P008R002A040
S015C003P025R002A012
S015C003P025R002A017
S015C003P025R002A020
S015C003P025R002A021
S015C003P025R002A030
S015C003P025R002A033
S015C003P025R002A034
S015C003P025R002A036
S015C003P025R002A037
S015C003P025R002A044
S016C001P019R002A040
S016C001P025R001A011
S016C001P025R001A012
S016C001P025R001A060
S016C001P040R001A055
S016C001P040R002A055
S016C002P008R001A011
S016C002P019R002A040
S016C002P025R002A012
S016C003P008R001A011
S016C003P008R002A002
S016C003P008R002A003
S016C003P008R002A004
S016C003P008R002A006
S016C003P008R002A009
S016C003P019R002A040
S016C003P039R002A016
S017C001P016R002A031
S017C002P007R001A013
S017C002P008R001A009
S017C002P015R001A042
S017C002P016R002A031
S017C002P016R002A055
S017C003P007R002A013
S017C003P008R001A059
S017C003P016R002A031
S017C003P017R001A055
S017C003P020R001A059
  • 缺失值剔除代码

import os
import shutil


F = open('Miss_Value.txt', encoding='utf-8')  # 将上文中的缺失值名称保存为txt文件
lines = []
for line in F:
    lines.append(line.strip())

path1 = "./Cross-Subject/Train"      # 文件夹目录,划分数据集操作中按照人物ID分好的训练集
files1 = os.listdir(path1)    # 得到文件夹下的所有文件名称
path2 = "./Cross-Subject/Test"      # 文件夹目录,划分数据集操作中按照人物ID分好的测试集
files2 = os.listdir(path2)    # 得到文件夹下的所有文件名称
path3 = "./Cross-View/Train"      # 文件夹目录,划分数据集操作中按照相机ID分好的训练集
files3 = os.listdir(path3)    # 得到文件夹下的所有文件名称
path4 = "./Cross-View/Test"      # 文件夹目录,划分数据集操作中按照相机ID分好的测试集
files4 = os.listdir(path4)    # 得到文件夹下的所有文件名称

for file in files1:  # 遍历文件夹
    for i in range(302):
        if lines[i] in file:
            file = os.path.join(path1, file)
            shutil.move(file, './Cross-Subject/Train-Miss')
for file in files2:  # 遍历文件夹
    for i in range(302):
        if lines[i] in file:
            file = os.path.join(path2, file)
            shutil.move(file, './Cross-Subject/Test-Miss')
for file in files3:  # 遍历文件夹
    for i in range(302):
        if lines[i] in file:
            file = os.path.join(path3, file)
            shutil.move(file, './Cross-View/Train-Miss')
for file in files4:  # 遍历文件夹
    for i in range(302):
        if lines[i] in file:
            file = os.path.join(path4, file)
            shutil.move(file, './Cross-View/Test-Miss')

PS:缺失样本在各个文件夹中的具体个数如下,注意核对

Cross-View:
Train:274 
Test:28
Cross-Subject:
Train:229
Test:73

最终可得到如下所示数据:
在这里插入图片描述
在这里插入图片描述
另:后续处理待补充。

  • 0
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值