Giter VIP home page Giter VIP logo

hallo-annotation's Introduction

HALLO annotation tool

Introduction

Software Architecture

Local/Dev Instance Setup

Deployment in the Cloud

Deleting Local Instance


Introduction

The HALLO (Humans and ALgorithms Listening for Orcas) annotation tool is a web application for analyzing and annotating audio files, consisting of three main modules: front-end(user interface), back-end(data processing) and database. It is licensed under the GNU GPLv3 licens and hence freely available for anyone to use and modify (including for commercial purposes) as long as the same license is kept. The tool was designed to facilitate the inteaction between machine learning developers and expert bioacousticians working to create automated detectors and classifiers for orcas (Orcinus orca). However, we believe it to be flexible enough to be used or modified for many other projects.

The main functions are:

  1. Managing raw audio files, segmenting and compressing them in the back-end and generating the corresponding spectrograms.

  2. Users can register as two roles, Model developer and Annotator. Model developers can create batches containing audio segments, which can then be assigned to one or more Annotators, or import annotations created by machine and assign them to annotators. Annotators can wrok on the spectrogram of the audio segments, review the corresponding annotations, create new annotations, and listen to the audio.

  3. The generated annotations can be exported to csv format for further analysis or use in machine learning development.


Software Architecture

Hallo application tools use a modular design, with two separate applications for the front-end and back-end, communicating data through the Restful API protocol.

The backend is implemented using the Django framework, and Ketos is installed as the core component for processing audio, providing a set of standard APIs for the frontend to consume.

The front-end is built using the React framework and runs in most modern browsers. A clean and easy-to-use design is used, focusing on synchronizing, filtering and quickly finding data.

Hallo annotation interface


Installation

The HALLO annotation tool is composed of two parts: front-end and back-end. The back-end needs to be installed on a server that can read data directly, and the front-end can be installed on any server.

Two methods of installation are described below, one for installing locally (for use in one single computer, for example), and the other is installed on a remote server for multiple users to access and use. Both ways use docker as a carrier to install.

Users can also adapt the code to their needs and deploy it according to their own installation environment.

Local instance installation guide


Prerequisite

In the example of a local installation, the HALLO annotation tool runs in a few Docker containers and requires Docker and Docker-compose to be pre-installed on the system.

Steps

  1. The HALLO annotation tool needs to be installed in the same directory as the audio files, and the audio files need to be contained in a folder called audio.

    Clone this repo and put it in the same folder where the audio folder located.

    A typical directory structure is:

    Example_Project_folder
     ├─ audio
     └─ hallo_annotation
    
  2. In the code base, the file docker-compose.dev.yml is used to provide a basic example. To use this file you need to create an env (eg .evn.dev) to configure some environment parameters.

    An example of environmental parameters

    # Database
    POSTGRES_DB=name_of_the_database
    POSTGRES_USER=username
    POSTGRES_PASSWORD=password
    
    # PGadmin
    PGADMIN_DEFAULT_EMAIL=login_email_address
    PGADMIN_DEFAULT_PASSWORD=password
    
    # Django key
    DJANGO_SECRET_KEY=The_django_secret_key
    
    
  3. From the hallo_annotation folder, run docker command as below. If you are using linux, you might need to add sudo.

     docker-compose -f docker-compose.dev.yml --env-file .env.dev up -d
    
  4. If all goes well, you can use docker ps to check the containers' status.

    hallo_annotation % docker ps
    CONTAINER ID   IMAGE                       COMMAND                  CREATED          STATUS          PORTS                           NAMES
    55052170d523   hallo_annotation_frontend   "docker-entrypoint.s…"   34 minutes ago   Up 33 minutes   0.0.0.0:3000->3000/tcp          hallo_frontend
    7337d62ba365   hallo_annotation_backend    "bash -c 'python man…"   17 hours ago     Up 33 minutes   0.0.0.0:8000->8000/tcp          hallo_backend
    416cfb0e2dd0   dpage/pgadmin4              "/entrypoint.sh"         17 hours ago     Up 33 minutes   443/tcp, 0.0.0.0:5050->80/tcp   hallo_pgadmin
    ec8b3350a851   postgres:13                 "docker-entrypoint.s…"   17 hours ago     Up 33 minutes   0.0.0.0:5432->5432/tcp          hallo_postgres_db
    
  5. A superuser needs to be created at the backend to set up the groups. In the same folder, use this command to get in the backend container.

    docker-compose -f docker-compose.dev.yml --env-file .env.dev run backend dash
    

    Then create the superuser for the Django Admin:

    python manage.py createsuperuser
    
  6. The HALLO annotation tool uses Django's Admin panel to manage user permissions. For the first time, you need to log in and create groups and assign permissions for each group. The Django backend is at: http://localhost:8000/admin/, and you can use the superuser account you just created to log in.

    After logging in, create three user groups in the Groups page (Case sensitive).

    1. Admin
    2. Model Developer
    3. Annotator
    

    New users will need to be manually added to a group here after they have completed registration. Permission control here only affects the operation permissions of the admin interface, and does not affect the permissions when using the HALLO annotation software. After users are added to the appropriate group, they will enter the applicable user interface once logging into the software, and the group is only used here to differentiate user roles.

    Permissions for different user groups:

    • Admin: Has permission to manually create users in the admin interface.
      Admin user permissions

      You aslo need to give a admin user permission to log in to the admin screen by setting this user to is staff.
      Set user to staff

    • Model Developer and Annotators: Keep the permissions blank as they don't have access to the admin interface.

  7. The user interface will be available at: http://localhost:3000/


Deployment in the cloud

The HALLO annotation tool is based on a modular design and can be flexibly deployed on cloud servers.Depending on the specific network topology, multiple deployment options can be implemented. Each service can be deployed on a separate server or a centralized deployment on a single server using a NGINX web server. Below is a brief description of two deployment methods.

Using a vitrual machine with public IP or domain name.

Deployment with public IP address

In this scenario, the application is deployed on a server with a public IP, and users can directly access the address or domain name of this server to use the service.

Using a virtural machine with ingress controller.

Deployment with ingress controller

If the service needs to be deployed in a network with an ingress controller, either using a sub-domain or domian subdirectory to access the service, some configurations in the code need to be adjusted.

In the configuration of the front-end service, you need to add the corresponding homepage configuration in the package.json file.

In the Django settings of the backend service, you need to adjust the corresponding MEDIA_URL, STATIC_URL and LOGIN_REDIRECT_URL configurations.

The basic setup for this deployment is already done in the code base, and a minimal docker-compose.sfu.yml file is provided to demonstrate how to run this configuration.


Deleting the local instance

If you need to remove the software completely, or want to reinstall a fresh version, consider the following steps:

  1. Stop the docker containers

    docker-compose -f docker-compose.dev.yml --env-file .env.dev down
    
  2. List the images that were used by HALLO

    $docker image ls
    REPOSITORY                  TAG       IMAGE ID       CREATED             SIZE
    hallo-annotation_frontend   latest    900f03c5b6d1   About an hour ago   2.03GB
    hallo-annotation_backend    latest    5b9eb01ed370   About an hour ago   3.26GB
    postgres                    13        b67cf799bada   12 days ago         373MB
    dpage/pgadmin4              latest    40a516ee7dea   3 weeks ago         341MB
    
  3. Delete the images by copying the image ids after command docker image rm, for example:

    docker image rm 900f03c5b6d1 5b9eb01ed370
    
  4. Remove the volum (note that this will clear the database):

    docker volume rm hallo-annotation_db_data hallo-annotation_pgadmin_data
    
  5. Use system prune to clean up the system (optional):

    docker system prune
    

hallo-annotation's People

Contributors

yue-su avatar fsfrazao avatar

Watchers

Paul Maček avatar Steven Bergner avatar  avatar Dave Campbell avatar Ruth Joy avatar Jillian Anderson avatar

hallo-annotation's Issues

Spectrogram zoom function

Hi @yue-su , hi @fsfrazao

It would be very useful to have more options to zoom on the spectrogram. With the default zoom level, I find it challenging to draw sufficently precise bounding boxes. Example shown below.

There is 2x zoom option, but the bounding boxes are not shown in this mode. In any case, I think we would want more zoom options, independent for time and frequency axis.

Oliver

Screenshot from 2022-10-20 09-28-54

Option to adjust dB color scale on spectrogram

In some cases, calls can be difficult to see in the spectrogram because the dB color range is not well adjusted. This happens e.g. when the 0 frequency bin has much higher intensity than all the other frequency bins.

This problem could be solved by exposing the vmin and vmax parameters of the matplotlib plot function, so the user can adjust the extremes of the dB color range manually.

BUG: Annotation UI comment field not taking text input

As an authenticated annotator,
when I create a new annotation or edit an existing one,
I can select the Comment field for an annotation (and see my cursor ready there),
but when I try to type text nothing happens.

I've tested this on OSX (12.6) / Macbook (16-inch, 2019) and get same behavior on both Chrome (v.107.0.5304.110) and Safari(Version 16.0 (17614.1.25.9.10, 17614)).

Annotation fixes and enhancement

There is an issue when importing the annotation and creating the segments.

The annotations themselves are imported correctly however the created segments are not. There are to issues here.

  1. The first annotation groups are concatenated into a single segment. So if i have 3 annotations, i expect to create 3 segments. Instead, the 3 annotations are grouped into one segment with length starting from the start time of the first annotation and end time of the second annotation. This could be because all 3 annotations are close to each other (but not overlapping).
  2. Segments created by the annotation are padded with one second before the start and one second after the end of the annotation.

See images below for the issues:

Screenshot from 2022-04-28 16-27-01
Screenshot from 2022-04-28 16-26-54

We could consider adding the segments separate from the annotation.

Add link to signal catalog(s)

As an authenticated annotator,
Actively engaged in the work within the Annotation Panel,
Once I have specified the species (and in some cases ecotype),
I want a handy link to the relevant signal catalog.

Ideally, it would be somewhere near the current "Call Type" field so I don't have to move mouse very far to select it. As is, I'm using side-by-side browser windows to iteratively compare a signal in question with a catalog, e.g. for SRKW calls it looks like this:

Screen Shot 2022-11-18 at 12 35 35 PM

Stretch goal: maybe some day there could be a "Compare" feature where e.g. I can easily re-play the signal I'm in the process of annotating in quick succession with possible matches from a catalog, like the online John Ford one for SRKW calls?

Option to amplify sound

For some audio files, the sound is so low that even with the amplification set to max in the fronted, the sound remains difficult to hear. This is e.g. the case for ONC audio files. To handle such cases, there should be an option for the user to further amplify the sound.

In the backend, this could be implemented by simply multiplying the waveform by a factor. For example, to amplify the intensity by a linear factor a:

from ketos.audio.waveform import Waveform
wf = Waveform.from_wav("audio.wav")
wf.data *= a
wf.to_wav("amplified_audio.wav")

or, with the amplification specified by logarithmic factor a_dB,

from ketos.audio.waveform import Waveform
wf = Waveform.from_wav("audio.wav")
wf.data *= np.power(10, a_dB / 20)
wf.to_wav("amplified_audio.wav")

Audio channel for stereo recordings

I'm not sure if this is an issue or not - but what happens when the audio file has multiple channels?
Can the user select a channel or does the web app simply default to the 1st channel?
There should be an option to select channel, since sometimes the relevant data is not in the 1st channel.

Add J/K/L option to Pod dropdown choices

I have a situation where the recording I'm annotating was made when all three SRKW pods were present.

However, the UI doesn't offer the "J/K/L" or "All" option that I need. Instead it looks like this:

Screenshot 2023-04-05 at 5 46 45 PM

Proposed solution:

  1. Short-term: add a J/K/L solution for SRKW pods, or and "All" option
  2. Longer-term: populate the Pod dropdown with all pod options for the previously selected ecotype. This will lead to a pretty long menu for e.g. NRKWs, but it will be shorter than listing all NRKW and SRKW pods!

Relabel "Call type" to "Signal type" and add KW whistles and clicks

As an authenticated annotator,
I want to be able to label not only SRKW calls, but also SRKW whistles and clicks,
So that I can create test and training data for non-call binary classifiers or multiclass models.

Here is the current UI:
Screenshot 2023-04-05 at 5 37 08 PM

Proposed solutions

  1. Add an "Other field" to the existing UI and instruct annotators to add the non-call signal label in the comment field
  2. Rename the "Call type" drop-down UI element to the more generic "Signal type" and then add "whistle" and "click" as choices.

Remove "offset" field from annotation tables

The offset field would only be relevant if the start/end times were recorded relative to the beginning of the segment (as opposed to the beginning of the file).
This is how we thought we were going to record annotations at some point, but later we changed to keeping everything relative to the file.
So, the offset field is not needed and is just a residual from earlier iterations of the annotation format.

It can be removed from the app.

File system unresponsive when working with large quantities of files

There is an issue in the file system when working with a large quantity of files. In my case I have 2000+ files, and when i select all (or a large quantity of files) and click "include" or "exclude", at first nothing seems to happen. It will take a while for the files to be included and sometimes i get this error: A server/network error occurred. The server is not responding to the request, and may be restarted automatically

If this error occurs, the remaining files are not included or excluded.

The biggest issue here however, is that there is no visual indication that some processing is occurring. So it seems like the system isnt doing anything. The first time this happened, I thought the system didnt get the command so i tried again and again and ended up crashing the app.

My suggestion would be to add a loading circle to the panel only, and disable the scan/verify/delete/include/exclude buttons while any file processing is happening. This way, the user knows the system is processing their request and they can move on to another tab to do something else.

QOL suggestions

I have some quality of life suggestions. I will be updating this issue if I have more.

  • Tooltip is spectrogram settings. It wasnt immediately obvious what some settings were for some users. For instance, they though window length meant the length of the segment and not the stft setting for the spectrogram. I think a tooltip that users can hover over in some settings would be useful
  • When you log in as an annotator, the system seems to fetch every segment available during login. This can take a while if there are many segments (5000+), in addition, it seemed like the app got extremely laggy afterwards (unusable really). I am not 100% sure this is what happened. Would it not be best to have a buffer of about 40 segments in the immediate vicinity of the one the user is annotating, instead of loading everything at startup?
  • I think it is very cumbersome that the annotator has to click save every time they wish to change some annotation, and if you dont click save and move to a new annotation box, it will reset the changes. If I had to change this, I would remove the save button from every annotation and include one for the segment. Once the annotator is happy with the modification he can click save and it will submit and update in the server.

Admin panel permission documentation

Step 6 of the instructions for setting up a local environment requires an admin to set up 3 user groups. However in the admin panel, some permissions I have no idea what they are for. For instance, contenttypes or tokenblacklist etc. It would be nice having an example of which permissions should belong in the three user groups.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.