当我运行以下程序时
def generate_list(frame_path):
result = open('./labels/ucf_labels.txt','w')
for root_dir, dirs, files in os.walk(frame_path):
print('root_dir:', root_dir) # current dir
print('sub_dirs:', dirs) # all subdirectories under the current path
print('files:', files) # all non_directory sub_files in the current path
r = r'clip(.*)_'
re_frame = re.compile(r)
for frame_name in files:
frame_path = root_dir+'/'+frame_name
label = re.findall(re_frame,root_dir)[0] #frame2label mapping
result.write(frame_path+' '+str(label)+'\n')
我遇到以下错误:
Traceback (most recent call last):
File "/home/tl/frame_extract.py", line 51, in <module>
generate_list('./segments')
File "/home/tl/frame_extract.py", line 46, in generate_list
label = re.findall(re_frame,root_dir)[0] #frame2label mapping
IndexError: list index out of range
标签的索引似乎超出范围,但是我找不到解决方案。有人帮忙吗?