mcguirepr89 / BirdNET-Pi

A realtime acoustic bird classification system for the Raspberry Pi 4B, 3B+, and 0W2 built on the TFLite version of BirdNET.
Other
1.3k stars 139 forks source link

Date of "Detected species" with max confidence score #58

Closed DD4WH closed 3 years ago

DD4WH commented 3 years ago

In the "Databse view" there is a table with species sorted by maximum confidence scores, called "Detected species"

It seems the date for those events with max confidence score is not properly retrieved from the data base. In my case, it uses a date/time where there are no extracted recordings of that particular species.

Hmm, the more I investigate this, I get the impression, it is a feature of the automatic deleting of files! I did not know that the extracted files get deleted too! I do not think this is useful, but will think about this.

mcguirepr89 commented 3 years ago

This sounds like something that is not intended. I would really need to take a look through the actual database and compare that to the files to understand what is going on.

If there is any chance you'd be willing to host an AnyDesk session on your desktop/laptop so that I could take a look, I might be able to see what is going on. Otherwise, I think I would need to try to reproduce this, and I can say that I haven't encountered that yet on my system. I will also take a look through @CaiusX's system to see if that is happening there.

I will keep you posted on what I'm able to find. Please let me know if you can think of a way that I might be able to reproduce this on my end.

Also, double-check that there are no errors reported in the Extraction Log and that it seems to be firing every 10-15 seconds.

mcguirepr89 commented 3 years ago

I may have found the issue. It seems the updater doesn't restart the extraction.timer, which is responsible for triggering the extraction.service. I would bet that the files are still there (in Analyzed directories) and needs to have the extraction.timer re-triggered.

Try another update and then watch the Extraction log. I bet you'll see tons of extractions get created, then I bet you'll see the confidence scores and extractions corresponding as expected. After the update, be sure to change your crontabs back so that you can keep your raw data longer.

Also,

I did not know that the extracted files get deleted too! I do not think this is useful, but will think about this.

That doesn't happen -- either the extractions were made or not, but they do not get removed at any stage.

mcguirepr89 commented 3 years ago

Just a quick overview of cleanup.sh

#!/usr/bin/env bash
source /etc/birdnet/birdnet.conf

cd "${PROCESSED}" || exit 1
empties=($(find ${PROCESSED} -size 57c))
for i in "${empties[@]}";do
  rm -f "${i}"
  rm -f "${i/.csv/}"
done

if [[ "$(find ${PROCESSED} | wc -l)" -ge 100 ]];then
  ls -1t . | tail -n +100 | xargs -r rm -vv
fi
  1. The script enters the "Processed" directory. Files end up in the "Processed" directory only after they have been both analyzed by BirdNET-Lite and processed by the extraction.service. Files that have only been analyzed by BirdNET-Lite but have not yet been processed by the extraction.service will exist in directories marked "-Analyzed". Below is a "tree" view for today. It shows the raw recordings in the top branch, and the "Analyzed" files in the bottom branch. The Analyzed files have been analyzed by BirdNET-Pi but not yet processed by the extraction.service.
    /home/pi/BirdSongs/October-2021/
    ├── 28-Thursday
    │   ├── 2021-10-28-birdnet-10:16:52.wav
    │   └── 2021-10-28-birdnet-10:17:07.wav
    └── 28-Thursday-Analyzed
    ├── 2021-10-28-birdnet-10:16:37.wav
    └── 2021-10-28-birdnet-10:16:37.wav.csv
  2. "empties" is a variable array that combs through the Processed files for any empty ".csv" files (recordings for which BirdNET-Lite indicated no detections). For each empty .csv file it finds, it removes it and the WAVE file to which it corresponds.
  3. Last, the Processed files are sorted by time and only the most recent 100 are kept

I hope that overview is helpful for understanding how the cleanup.sh script currently runs.

mcguirepr89 commented 3 years ago

Hi @DD4WH I wanted to follow up with you to see if you were able to check on the extraction service to see if an issue there explains the missing extractions.

My best

mcguirepr89 commented 3 years ago

Closing without a response