Skip to content

APLOSE detections#400

Open
Gautzilla wants to merge 38 commits into
Project-OSmOSE:mainfrom
Gautzilla:annotation
Open

APLOSE detections#400
Gautzilla wants to merge 38 commits into
Project-OSmOSE:mainfrom
Gautzilla:annotation

Conversation

@Gautzilla

Copy link
Copy Markdown
Contributor

🖼️ Annotation results are coming to OSEkit!

How does it work

The idea is to be able to load APLOSE results csv into OSEkit as a collection of new Annotation objects:

annotations = Annotation.from_csv(Path("aplose_results.csv"))

The annotations could then be filtered thanks to their properties :

image
verified_annotations = [
    a for a in annotations if all(v.is_validated for v in a.verifications)
]

Using the Annotation with OSEkit

The Annotation class inherits from the Event class: its begin and end properties can be used to access the audio corresponding to the annotation box easily, e.g.:

from osekit.core.audio_data import AudioData
from osekit.core.audio_dataset import AudioDataset
from osekit.core.audio_file import AudioFile

afs = [AudioFile(...)] # Or even project.origin_files with the Public API

annotation_audio_dataset = AudioDataset(
    [
        AudioData.from_files(
            files=afs,
            begin=annotation.begin,
            end=annotation.end,
        )
        for annotation in annotations
    ]
)

# Then you could e.g. plot each spectrogram with SpectroDataset.from_audio_dataset

@Gautzilla Gautzilla self-assigned this Jun 2, 2026
@Gautzilla Gautzilla added the Feature A new feature to add to OSEkit label Jun 2, 2026
@coveralls

coveralls commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 98.992% (+0.04%) from 98.956% — Gautzilla:annotation into Project-OSmOSE:main

Comment thread src/osekit/core/annotation.py Outdated
Comment thread src/osekit/core/annotation.py Outdated
"confidence_indicator_label",
"confidence_indicator_level",
"label",
"level",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column names hasn't change on APLOSE side

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn good catch, I didn't see that my refactor affected also the dict keys!

I really should write an integration test before messing with everything 🥸

@Gautzilla Gautzilla changed the title [DRAFT] Annotation APLOSE detections Jun 10, 2026
@Gautzilla Gautzilla marked this pull request as ready for review June 10, 2026 15:04
@MaelleTtrt

MaelleTtrt commented Jun 15, 2026

Copy link
Copy Markdown
Member

Detection.from_csv() failed when I tried to read this file : path_aplose = Path(r"C:\Users\torterma\Desktop\cetiroise\CETIROISE_F5_25072023_Annotation_results_standardized.csv")

  File "C:\Users\torterma\Documents\Projets_Osmose\Git\OSEkit\.venv\Lib\site-packages\IPython\core\interactiveshell.py", line 3699, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<ipython-input-11-eae37ed4ec6f>", line 1, in <module>
    detections = Detection.from_csv(Path(path_aplose))
  File "C:\Users\torterma\Documents\Projets_Osmose\Git\OSEkit\src\osekit\core\detection.py", line 409, in from_csv
    return [cls.from_dict(record) for record in records]
            ~~~~~~~~~~~~~^^^^^^^^
  File "C:\Users\torterma\Documents\Projets_Osmose\Git\OSEkit\src\osekit\core\detection.py", line 320, in from_dict
    confidence_indicator = ConfidenceIndicator.from_relative_level_string(
        label=row["confidence_indicator_label"],
        relative_level_string=row["confidence_indicator_level"],
    )
  File "C:\Users\torterma\Documents\Projets_Osmose\Git\OSEkit\src\osekit\core\detection.py", line 178, in from_relative_level_string
    level, maximum_level = map(int, relative_level_string.split("/"))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'split'```


I think it's because the `confidence_indicator_level` column is empty. In this case, I think that `Detection.from_csv()` should return `None` in the `confidence_indicator_level` column.


@Gautzilla

Copy link
Copy Markdown
Contributor Author

Good catch, I indeed didn't notice the (if exists) part in the csv file description, I'll fix that shortyl!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature A new feature to add to OSEkit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants