Repository navigation
Add general detector + global moth model to example pipeline #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9f8b826
cf00c3e
9bd828b
fcfcd87
f042bf3
fcbed4d
ad1dbc5
9a6ad6d
7eeae15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Cache directories for models and dependencies | ||
| cache/ | ||
| huggingface_cache/ | ||
| pytorch_cache/ |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,233 @@ | ||||||
| """ | ||||||
| Simplified base classes for inference models without database dependencies. | ||||||
| Adapted from trapdata.ml.models.base but streamlined for processing service use. | ||||||
| """ | ||||||
|
|
||||||
| import json | ||||||
| import logging | ||||||
| from typing import Any | ||||||
|
|
||||||
| import torch | ||||||
| import torchvision.transforms | ||||||
|
|
||||||
| from .utils import get_best_device, get_or_download_file | ||||||
|
|
||||||
| logger = logging.getLogger(__name__) | ||||||
|
|
||||||
|
|
||||||
| # Standard normalization transforms | ||||||
| imagenet_normalization = torchvision.transforms.Normalize( | ||||||
| mean=[0.485, 0.456, 0.406], # RGB | ||||||
| std=[0.229, 0.224, 0.225], # RGB | ||||||
| ) | ||||||
|
|
||||||
| tensorflow_normalization = torchvision.transforms.Normalize( | ||||||
| mean=[0.5, 0.5, 0.5], # RGB | ||||||
| std=[0.5, 0.5, 0.5], # RGB | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
| class SimplifiedInferenceBase: | ||||||
| """ | ||||||
| Simplified base class for inference models without database or queue dependencies. | ||||||
| """ | ||||||
|
|
||||||
| name: str = "Unknown Inference Model" | ||||||
| description: str = "" | ||||||
| weights_path: str | None = None | ||||||
| labels_path: str | None = None | ||||||
| category_map: dict[int, str] = {} | ||||||
| num_classes: int | None = None | ||||||
| default_taxon_rank: str = "SPECIES" | ||||||
| normalization = tensorflow_normalization | ||||||
| batch_size: int = 4 | ||||||
| device: str | None = None | ||||||
|
|
||||||
| def __init__(self, **kwargs): | ||||||
| # Override any class attributes with provided kwargs | ||||||
| for k, v in kwargs.items(): | ||||||
| setattr(self, k, v) | ||||||
|
|
||||||
| logger.info(f"Initializing simplified inference class {self.name}") | ||||||
|
|
||||||
| self.device = self.device or get_best_device() | ||||||
| self.category_map = self.get_labels(self.labels_path) | ||||||
| self.num_classes = self.num_classes or len(self.category_map) | ||||||
| self.weights = self.get_weights(self.weights_path) | ||||||
| self.transforms = self.get_transforms() | ||||||
|
||||||
| self.transforms = self.get_transforms() | |
| self.transforms = None # Subclasses should set this after their own initialization |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call to SimplifiedInferenceBase.get_model in an initialization method is overridden by ResNet50Base.get_model.
This call to SimplifiedInferenceBase.get_model in an initialization method is overridden by TimmResNet50Base.get_model.
| self.model = self.get_model() | |
| self.model = None # Model should be initialized in subclass after all setup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: RolnickLab/antenna
Length of output: 4046
🏁 Script executed:
Repository: RolnickLab/antenna
Length of output: 30158
🏁 Script executed:
Repository: RolnickLab/antenna
Length of output: 16780
Clarify the container path for local model files.
Compose passes
MODEL_BASE_URLinto the container. A host directory outside the mounted example directory is not available inside either supported container. State that such a local model directory must be mounted and thatMODEL_BASE_URLmust use its container path. Otherwise, model loading can fail withFileNotFoundError.🤖 Prompt for AI Agents