Skip to content
Snippets Groups Projects
Commit eb9b6009 authored by Stephane Chavin's avatar Stephane Chavin
Browse files

Update 3 files

- /get_train_val_YOLO.py
- /get_yolo_detection.py
- /get_time_freq_detection.py
parent 77bbcec5
Branches
No related tags found
No related merge requests found
...@@ -27,7 +27,9 @@ def process_annotations(annotations_folder, duration, outdir, sr, names): ...@@ -27,7 +27,9 @@ def process_annotations(annotations_folder, duration, outdir, sr, names):
annotation_df['file'] = file_name annotation_df['file'] = file_name
annotation_df['idx'] = annotation_df['file'].str.split('_').str[-1].str.split('.').str[0] annotation_df['idx'] = annotation_df['file'].str.split('_').str[-1].str.split('.').str[0]
annotation_df['file'] = annotation_df['file'].str.rsplit('.', 1).str[0] + '.wav'
annotation_df['file'] = ['.'.join(x.file.split('.')[:-1]) for i, x in annotation_df.iterrows()]
annotation_df.file = annotation_df.file + '.wav'
annotation_df['annot'] = annotation_df['espece'].apply(lambda x: names[x]) annotation_df['annot'] = annotation_df['espece'].apply(lambda x: names[x])
......
...@@ -88,17 +88,15 @@ def export_split(entry, path, directory): ...@@ -88,17 +88,15 @@ def export_split(entry, path, directory):
if args.test == 1: if args.test == 1:
test = entry[2] test = entry[2]
#test.file = test.file.str.rsplit('.').str[0] test.file = ['.'.join(x.split('.')[:-1]) for num, x in enumerate(test.file)]
test.file = ['.'.join(x.rsplit('.')[:-1]) for num, x in enumerate(test.file)]
create_directory_if_not_exists(os.path.join(directory, 'images/test')) create_directory_if_not_exists(os.path.join(directory, 'images/test'))
create_directory_if_not_exists(os.path.join(directory, 'labels/test')) create_directory_if_not_exists(os.path.join(directory, 'labels/test'))
copy_files_to_directory(test.file, path, os.path.join(directory, 'labels/test'), 'txt') copy_files_to_directory(test.file, path, os.path.join(directory, 'labels/test'), 'txt')
copy_files_to_directory(test.file, os.path.join(path, '../images/all'), os.path.join(directory, 'images/test'), 'jpg') copy_files_to_directory(test.file, os.path.join(path, '../images/all'), os.path.join(directory, 'images/test'), 'jpg')
#val.file = val.file.str.rsplit('.').str[0]
val.file = ['.'.join(x.rsplit('.')[:-1]) for num, x in enumerate(val.file)] val.file = ['.'.join(x.split('.')[:-1]) for num, x in enumerate(val.file)]
#train.file = train.file.str.rsplit('.').str[0] train.file = ['.'.join(x.split('.')[:-1]) for num, x in enumerate(train.file)]
train.file = ['.'.join(x.rsplit('.')[:-1]) for num, x in enumerate(train.file)]
create_directory_if_not_exists(os.path.join(directory, 'images/train')) create_directory_if_not_exists(os.path.join(directory, 'images/train'))
create_directory_if_not_exists(os.path.join(directory, 'images/val')) create_directory_if_not_exists(os.path.join(directory, 'images/val'))
create_directory_if_not_exists(os.path.join(directory, 'labels/train')) create_directory_if_not_exists(os.path.join(directory, 'labels/train'))
......
...@@ -25,7 +25,7 @@ def process_data(args): ...@@ -25,7 +25,7 @@ def process_data(args):
df = df.reset_index() df = df.reset_index()
del df['index'] del df['index']
df['idx'] = df.file.str.split('_').str[-1].str.split('.').str[0] df['idx'] = df.file.str.split('_').str[-1].str.split('.').str[0]
df.file = df.file = ['.'.join(x.file.split('.')[:-1]) for i, x in df.iterrows()] + '.wav' df.file = ['.'.join(x.file.split('.')[:-1]) for i, x in df.iterrows()]
df.file = df.file + '.wav' df.file = df.file + '.wav'
# Define class names # Define class names
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment