Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions wadas/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@
# Date: 2024-08-14
# Description: module to keep track of WADAS version


__version__ = "v1.0.0a1"
__version__ = "v1.0.0.a2"
__dbversion__ = __version__
2 changes: 1 addition & 1 deletion wadas/domain/bear_detection_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class BearDetectionMode(CustomClassificationMode):
"""Bear Detection Mode class."""

def __init__(self):
super().__init__("bear")
super().__init__(["bear"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why it's a list now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because the custom classification mode allows to specify list of species to filter, not just a single item any more.

self.type = OperationMode.OperationModeTypes.BearDetectionMode
25 changes: 5 additions & 20 deletions wadas/domain/custom_classification_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import logging
from queue import Empty

from wadas.ai.models import txt_animalclasses
from wadas.domain.ai_model import AiModel
from wadas.domain.animal_detection_mode import AnimalDetectionAndClassificationMode
from wadas.domain.camera import media_queue
from wadas.domain.operation_mode import OperationMode
Expand All @@ -33,25 +31,12 @@
class CustomClassificationMode(AnimalDetectionAndClassificationMode):
"""Custom Classification Mode class."""

def __init__(self, custom_target_species=None):
def __init__(self, custom_target_species=OperationMode.cur_custom_classification_species):
super().__init__()
self.process_queue = True
self.type = OperationMode.OperationModeTypes.CustomSpeciesClassificationMode
self.custom_target_species = custom_target_species

def set_animal_species(self, target_animal_label):
"""Method to select animal to classify according to Ai model availability"""
if (
target_animal_label
in txt_animalclasses[AiModel.classification_model_version][AiModel.language]
):
self.custom_target_species = target_animal_label
logger.debug("%s species selected.", target_animal_label)
return True
else:
logger.error("The specified animal species is not handled by WADAS")
return False

def run(self):
"""WADAS custom classification mode"""

Expand All @@ -77,9 +62,9 @@ def run(self):
self.check_for_termination_requests()
if detection_event and self.enable_classification:
if detection_event.classification_media_path:
# Send notification and trigger actuators if the target animal is found
# Send notification and trigger actuators if any target animal is found
if any(
classified_animal["classification"][0] == self.custom_target_species
classified_animal["classification"][0] in self.custom_target_species
for classified_animal in detection_event.classified_animals
):
# Notification
Expand All @@ -97,9 +82,9 @@ def run(self):
self._show_processed_results(detection_event)
else:
logger.info(
"Target animal '%s' not found, found '%s' instead. "
"Target animals '%s' not found, found '%s' instead. "
"Skipping notification.",
self.custom_target_species,
", ".join(self.custom_target_species),
self.last_classified_animals_str,
)

Expand Down
2 changes: 1 addition & 1 deletion wadas/domain/operation_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class OperationModeTypes(Enum):
# Currently selected operation mode
cur_operation_mode = None
cur_operation_mode_type = None # We need this separately as object is deleted after op_mode run
cur_custom_classification_species = None
cur_custom_classification_species = []

# Signals
update_image = Signal(object)
Expand Down
59 changes: 20 additions & 39 deletions wadas/ui/qt/select_animal_species.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,31 @@
<x>0</x>
<y>0</y>
<width>318</width>
<height>113</height>
<height>258</height>
</rect>
</property>
<property name="windowTitle">
<string>Select animal species</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>301</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>301</width>
<height>61</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Select animal species to classify:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_select_species"/>
</item>
</layout>
</widget>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox_select_animal_species">
<property name="title">
<string>Select animal species:</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
Expand Down
Loading
Loading