text
stringlengths
1
93.6k
# purpose - splits the DataFrame into smaller of max size chunkSize (last is smaller)
def split_dataframe(df, chunk_size=1000):
list_of_df = list()
number_chunks = len(df) // chunk_size + 1
for i in range(number_chunks):
list_of_df.append(df[i*chunk_size:(i+1)*chunk_size])
return list_of_df
def export_text2xlsx(infile, outfile, field_delimiter, number):
df = pd.read_csv(infile, delimiter=field_delimiter, engine='python')
rows_number = df.shape[0]
if rows_number > number:
data_frames = split_dataframe(df, number)
frame_number = 1
for frame in data_frames:
filename, ext = os.path.splitext(outfile)
excel_file = "{}_{}.xlsx".format(filename, frame_number)
writer = ExcelWriter(excel_file, engine='xlsxwriter')
frame.to_excel(writer, 'sheet1')
writer.save()
frame_number += 1
else:
writer = ExcelWriter(outfile)
df.to_excel(writer, 'sheet1')
writer.save()
if __name__ == '__main__':
args = parser.parse_args()
infile = args.infile
outfile = args.outfile
delimiter = args.delimiter
lines_number = args.lines_number
export_text2xlsx(infile, outfile, delimiter, lines_number)
# <FILESEP>
import torch
import clip
label_text_map = []
with open('text/ntu120_label_map.txt') as infile:
lines = infile.readlines()
for ind, line in enumerate(lines):
label_text_map.append(line.rstrip().lstrip())
paste_text_map0 = []
with open('text/synonym_openai_t01.txt') as infile:
lines = infile.readlines()
for ind, line in enumerate(lines):
temp_list = line.rstrip().lstrip().split(',')
paste_text_map0.append(temp_list)
paste_text_map1 = []
with open('text/sentence_openai_t01.txt') as infile:
lines = infile.readlines()
for ind, line in enumerate(lines):
temp_list = line.rstrip().lstrip().split('.')
while len(temp_list) < 4:
temp_list.append(" ")
paste_text_map1.append(temp_list)
paste_text_map2 = []
with open('text/pasta_openai_t01.txt') as infile:
lines = infile.readlines()
for ind, line in enumerate(lines):
temp_list = line.rstrip().lstrip().split(';')
paste_text_map2.append(temp_list)
ucla_paste_text_map0 = []
with open('text/ucla_synonym_openai_t01.txt') as infile:
lines = infile.readlines()
for ind, line in enumerate(lines):
temp_list = line.rstrip().lstrip().split(',')
ucla_paste_text_map0.append(temp_list)
ucla_paste_text_map1 = []
with open('text/ucla_pasta_openai_t01.txt') as infile:
lines = infile.readlines()
for ind, line in enumerate(lines):
temp_list = line.rstrip().lstrip().split(';')
ucla_paste_text_map1.append(temp_list)
def text_prompt():
text_aug = [f"a photo of action {{}}", f"a picture of action {{}}", f"Human action of {{}}", f"{{}}, an action",
f"{{}} this is an action", f"{{}}, a video of action", f"Playing action of {{}}", f"{{}}",