<jupyter_start><jupyter_text>思路整理根据train.txt和val.txt获取每一个视频文件路径对每个视频    使用openpose生成预测文件        将预测文件打包为数据和标签        将数据和标签存入对应文件中<jupyter_code># class Struct():
#     pass
# arg=Struct()
# arg.data_path="../data/Skating"
# arg.out_folder="../output/Skating"

# arg.trainfile=os.path.join(arg.data_path,"train.csv")
# arg.testfile=os.path.join(arg.data_path,"val.csv")
# arg.labelfile=os.path.join(arg.data_path,"classInd.csv")

# arg.openpose="/home/jiangdong/opt/openpose/build"
# arg.model_folder="../models"
# openpose = '{}/examples/openpose/openpose.bin'.format(arg.openpose)

# def _count_lines(filename):
#     with open(filename) as f:
#         count=-1
#         for count,_ in enumerate(f):
#             pass
#         count+=1
#     return count

# def _video_loader(filename):
#     with open(filename) as f:
#         for line in f.readlines():
#             info=line.strip()
#             video_name , _,label=info.split(" ")
#             yield video_name,str(int(label)+1)

# def pose_estimation(openpose,out_folder,video_path,model_folder,info):
#     video_name=video_path.split('/')[-1].split('.')[0]
#     output_snippets_dir=os.path.join(out_folder,'openpose_estimation/snippets/{}'.format(video_name))
#     output_sequence_dir = os.path.join(out_folder,'data/')
#     output_sequence_path = '{}/{}.json'.format(output_sequence_dir, video_name)
#     # pose estimation
#     openpose_args = dict(
#         video=video_path,
#         write_json=output_snippets_dir,
#         display=0,
#         render_pose=0, 
#         model_pose='COCO',
#         model_folder=model_folder)
#     command_line = openpose + ' '
#     command_line += ' '.join(['--{} {}'.format(k, v) for k, v in openpose_args.items()])
#     shutil.rmtree(output_snippets_dir, ignore_errors=True)
#     os.makedirs(output_snippets_dir)
#     print(command_line)
#     os.system(command_line)
#     # pack openpose ouputs
#     video = utils.video.get_video_frames(video_path)
#     height, width, _ = video[0].shape
#     video_info = utils.openpose.json_pack(
#         output_snippets_dir, video_name, width, height, label_index=info["label_index"],label=info["label"])
#     if not os.path.exists(output_sequence_dir):
#         os.makedirs(output_sequence_dir)
#     with open(output_sequence_path, 'w') as outfile:
#         json.dump(video_info, outfile)
#     if len(video_info['data']) == 0:
#         print('Can not find pose estimation results of %s'%(video_name))
#         return
#     else:
#         print('%s Pose estimation complete.'%(video_name))    
# print(os.getcwd())
# label_names={}
# with open(arg.labelfile) as lf:
#     for line in lf.readlines():
#         index,label_name=line.strip().split(" ")
#         label_names[index]=label_name
# print(label_names)
# part = ['train', 'val']
# for p in part:
#     csvfile=os.path.join(arg.data_path,"{}.csv".format(p))
#     label_file={}
#     total_count = _count_lines(csvfile)
#     count=0
#     for nameinfo,label in _video_loader(csvfile):
#         try:
#             filename=nameinfo.split('/')[3]+".mp4"
#             category=filename.split("_")[0]
#             info={}
#             info['label_index']=int(label)
#             info['has_skeleton']=True
#             info['label']=label_names[label]
#             label_file[filename]=info
#             video_path = os.path.join(arg.data_path,category,filename)
#             pose_estimation(openpose,arg.out_folder,video_path,arg.model_folder,info)
#             count+=1
#             print("%4.2f %% of %s has been processed"%(count*100/total_count,p))
#         except Exception as e:
#             print(e)
#     label_save_path=os.path.join(arg.out_folder,"{}_label.json".format(p))
#     with open(label_save_path,"w") as f:
#         json.dump(label_file,f)
line="/share/SkatingFlow/3Lutz_n28_p10_g04"
print(line.split('/')[3].split("_")[0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15866121614716402, 'fraction_numerical': 0.007153806847215125, 'mean_word_length': 3.2324324324324323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '531757', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1409, 'n_words': 185, 'path': 'tools/script.ipynb', 'repo_name': 'HaxiSnake/skeleton_frame', 'size': '3914'}