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

correction bug

parent 79b22109
Branches
No related tags found
No related merge requests found
......@@ -14,6 +14,8 @@ args = parser.parse_args()
path_to_data = args.path_to_data
folder = 'Spectrogramme/'
DURATION = 8
NB_IMG_PER_REC = 30
count = 0
......@@ -22,14 +24,14 @@ df = pd.read_csv(str(args.file+'.csv'))
for i in tqdm(df.groupby('dir')): #la colonne dir correspond au path
count = 0
for j in range (30): #30*8 secondes - 30*2 secondes (overlap) = 180 secondes affichées sur 30 images : n'affiche que les 3 premières minutes d'un enregistrement
for j in range (NB_IMG_PER_REC): #30*8 secondes - 30*2 secondes (overlap) = 180 secondes affichées sur 30 images : n'affiche que les 3 premières minutes d'un enregistrement
filename = str(path_to_data+i[0])
if count ==0:
duration = 8
duration = DURATION
offset = 0
else :
duration = 8
duration = DURATION
ffset = offset + 6
try:
y, sr = librosa.load(filename, offset = offset, duration = duration)
......@@ -62,7 +64,3 @@ for i in tqdm(df.groupby('dir')): #la colonne dir correspond au path
plt.savefig(str(folder+name+'.jpg'))
count+=1
......@@ -37,6 +37,9 @@ df.rename(columns={'min_frequency':'min_freq'},inplace=True)
df.rename(columns={'max_frequency':'max_freq'},inplace=True)
df.rename(columns={'avg_frequency':'midl_y'},inplace=True)
df['max_freq'].fillna(9000,inplace = True)
df['min_freq'].fillna(1000,inplace = True)
df['d_annot'] = df.stop - df.start
df['midl'] = (df.stop + df.start)/2
df['Path'] = ''
......
......@@ -10,7 +10,7 @@ import ipdb
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='RATIO')
parser.add_argument('-r','-ratio', type=float, default=0.7,help = 'Train Ratio (val = 1 - ratio)')
parser.add_argument('-p','--path_to_data', type=str, help = 'Path of the folder that contain the recodings',required=True)
parser.add_argument('-d','--direction', type=str, help = 'Direction to export the spectrogram and the .txt files',required=True)
parser.add_argument('-d','--direction', type=str, help = 'Direction of the folder to export the spectrogram and the .txt files',required=True)
args = parser.parse_args()
path = str(args.path_to_txt)
......@@ -31,6 +31,9 @@ for i in tqdm(os.listdir(path)):
tab= pd.DataFrame(columns = ['file','espece','x','y','w','h'])
tab2 = pd.DataFrame(columns = ['file','espece','x','y','w','h'])
if table.columns[1] == 'Unnamed: 1': #remove the annotation file that contains error
continue
if len (table) == 0:
for j in table.columns:
l.append(j)
......@@ -104,7 +107,7 @@ for i,row in train.iterrows():
shutil.copy2(str(path+'labels/'+row.file+'.txt'),str(direction+'labels/train/'+row.file+'.txt'))
shutil.copy2(str(path+'../images/all/'+row.file+'.jpg'),str(direction+'images/train/'+row.file+'.jpg'))
with open(str(direction+'custom_data.yaml','w') as f:
with open(str(direction+'custom_data.yaml'),'w') as f:
f.write('train : '+direction+'images/train\n')
f.write('test : '+direction+'images/val\n')
f.write('nc : ' + len(tab)+'\n')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment