Skip to content

Commit

Permalink
[ADD] to_annotation_sheet.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
BenCretois committed Jan 10, 2025
1 parent 2587abf commit fef6029
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,28 @@ python3 src/global_sampler.py

:star: Note that this `parquet` file will contain `$NUM_SEGMENT` random segments with the `$THRESHOLD` indicated in the `config_connection.yaml`.

3- Extract the detections!
4- Extract the detections!

```bash
./extract.sh
```

## Format for annotation

To annotate the extracted segments, we create a `csv` file per species. The `csv` list the segments to annotate and add a few columns for the annotator to fill. To help create the `csv` files, the repository contains a bash script `to_annotation_sheet.sh`.

Be sure to change the input and output in the script L4 and L5:

```bash
BASE_DIR= ./extracted_segments # Folder where all the segments are stored
OUTPUT_DIR= ./csv # Folder that receives the csv files
```
Then run the script:

```bash
./to_annotation_sheet.sh
```




38 changes: 38 additions & 0 deletions to_annotation_sheet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Define the base directory containing the species folders and output directory
BASE_DIR="for_tom/segments"
OUTPUT_DIR="/home/benjamin.cretois/Code/birdnetfs/for_tom/csv"

# Create the output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

# Header for the CSV file
CSV_HEADER="Filename,Species (BirdNET),BirdNET correct? (Yes/No),If BirdNET incorrect, true species ID or sound source?,How confident are you? (High/Medium/Low),Reason for misidentification? (Related species /Anthropogenic sound/Mimic/No call/Other),Comments"

# Iterate over each species folder in the base directory
for species_folder in "$BASE_DIR"/*; do
if [ -d "$species_folder" ]; then
# Get the species name from the folder name
species_name=$(basename "$species_folder")

# Define the output CSV file
csv_file="$OUTPUT_DIR/$species_name.csv"

# Write the CSV header to the file
echo "$CSV_HEADER" > "$csv_file"

# Iterate over the files in the species folder
for file in "$species_folder"/*; do
if [ -f "$file" ]; then
# Get the filename without the path
filename=$(basename "$file")

# Add a row to the CSV with the filename and the species name
echo "$filename,$species_name,,,,,," >> "$csv_file"
fi
done
fi
done

echo "CSV generation complete. Files saved in $OUTPUT_DIR."

0 comments on commit fef6029

Please sign in to comment.