【发布时间】:2021-05-25 14:26:18
【问题描述】:
我有一个数据集,其中包含约 148,000 个视频文件夹,每个文件夹都转换为平均约 30 帧的帧。
我有 2 个用于训练和验证的 csv 文件。我已经能够通过以下代码创建一个注释文件来标记我需要的数据。
import numpy as np
import pandas as pd
import os
Dir = "./DataSet/20bn-jester-v1/"
classes = ['No gesture', 'Thumb Down', 'Thumb Up','Swiping Down', 'Swiping Up', 'Swiping Left', 'Swiping Right' ]
class_dict = {k: v for v, k in enumerate(classes)}
#Will count frames in each example
def count_frame(folder_name):
return len([frame for frame in os.listdir(Dir+str(folder_name)) if os.path.isfile(os.path.join(Dir+str(folder_name), frame))])
#reading training csv
df = pd.read_csv('DataSet/jester-v1-train.csv',sep=';',header=None)
# Getting the data for only selected classes
df = df[df[1].isin(classes)]
# Convert class labels into int value(Encoding)
df[3] = df[1].map(class_dict).astype(str)
# Apply the Count frame function and store the data in column 2
df[2] = df[0].apply(count_frame).astype(int)
# Re arrange the columns
# Where column 0 is folder name, column 1 is start frame, column 2 is end frame and column 3 is label
df = df[[0, 1, 2, 3]]
# setting column 1 values equal to 1
df[1] = 1
df
这给了我以下结果。
我做同样的验证。我只是不知道如何使用以下信息并使用它将第 0 列中的以下文件分隔到一个单独的文件夹中,因为我想将其上传到谷歌驱动器,但由于文件数量庞大且我的互联网是土豆,我无法将整个数据集上传到驱动器
编辑:我已将文件 tar 压缩以尝试将其上传到谷歌驱动器。有没有办法用文本文件中的文件名解压缩特定文件?
【问题讨论】:
标签: python pandas csv jupyter-notebook google-colaboratory