biodex 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. biodex-1.0.1/.github/workflows/ci.yml +75 -0
  2. biodex-1.0.1/.github/workflows/release.yml +77 -0
  3. biodex-1.0.1/.gitignore +72 -0
  4. biodex-1.0.1/.pre-commit-config.yaml +17 -0
  5. biodex-1.0.1/CHANGELOG.md +80 -0
  6. biodex-1.0.1/CITATION.cff +14 -0
  7. biodex-1.0.1/CONTRIBUTING.md +33 -0
  8. biodex-1.0.1/Dockerfile +39 -0
  9. biodex-1.0.1/Dockerfile.gpu +38 -0
  10. biodex-1.0.1/LICENSE +21 -0
  11. biodex-1.0.1/PKG-INFO +181 -0
  12. biodex-1.0.1/README.md +119 -0
  13. biodex-1.0.1/SECURITY.md +31 -0
  14. biodex-1.0.1/app.py +344 -0
  15. biodex-1.0.1/biodex/__init__.py +14 -0
  16. biodex-1.0.1/biodex/__main__.py +8 -0
  17. biodex-1.0.1/constraints.txt +16 -0
  18. biodex-1.0.1/core/__init__.py +55 -0
  19. biodex-1.0.1/core/analytics.py +113 -0
  20. biodex-1.0.1/core/audit_log.py +63 -0
  21. biodex-1.0.1/core/batch.py +259 -0
  22. biodex-1.0.1/core/batch_report.py +73 -0
  23. biodex-1.0.1/core/classifier.py +83 -0
  24. biodex-1.0.1/core/cli.py +464 -0
  25. biodex-1.0.1/core/config.py +99 -0
  26. biodex-1.0.1/core/detector.py +290 -0
  27. biodex-1.0.1/core/exif_utils.py +122 -0
  28. biodex-1.0.1/core/exports.py +635 -0
  29. biodex-1.0.1/core/models/__init__.py +38 -0
  30. biodex-1.0.1/core/models/base.py +72 -0
  31. biodex-1.0.1/core/models/edge.py +72 -0
  32. biodex-1.0.1/core/models/megadetector.py +151 -0
  33. biodex-1.0.1/core/models/registry.py +136 -0
  34. biodex-1.0.1/core/models/speciesnet.py +258 -0
  35. biodex-1.0.1/core/progress.py +79 -0
  36. biodex-1.0.1/core/quick_demo.py +152 -0
  37. biodex-1.0.1/core/types.py +268 -0
  38. biodex-1.0.1/core/ui_entry.py +16 -0
  39. biodex-1.0.1/core/video.py +230 -0
  40. biodex-1.0.1/core/visualization.py +364 -0
  41. biodex-1.0.1/desktop/README.md +12 -0
  42. biodex-1.0.1/desktop/__init__.py +1 -0
  43. biodex-1.0.1/desktop/launcher.py +110 -0
  44. biodex-1.0.1/docs/adr-core-package.md +19 -0
  45. biodex-1.0.1/docs/adr-pluggable-models.md +50 -0
  46. biodex-1.0.1/docs/biodex_banner.png +0 -0
  47. biodex-1.0.1/docs/biodex_icon.png +0 -0
  48. biodex-1.0.1/docs/biodex_logo.png +0 -0
  49. biodex-1.0.1/docs/demo.md +38 -0
  50. biodex-1.0.1/docs/desktop.md +38 -0
  51. biodex-1.0.1/docs/launch/linkedin.md +78 -0
  52. biodex-1.0.1/docs/launch/product-hunt.md +75 -0
  53. biodex-1.0.1/docs/publishing.md +99 -0
  54. biodex-1.0.1/docs/roadmap.md +50 -0
  55. biodex-1.0.1/docs/screenshots/.gitkeep +11 -0
  56. biodex-1.0.1/docs/v1.1-plan.md +101 -0
  57. biodex-1.0.1/examples/README.md +62 -0
  58. biodex-1.0.1/examples/ecosentinel_integration.py +119 -0
  59. biodex-1.0.1/examples/manifest.json +47 -0
  60. biodex-1.0.1/examples/sample.jpg +0 -0
  61. biodex-1.0.1/packaging/README.md +12 -0
  62. biodex-1.0.1/packaging/biodex-desktop.spec +130 -0
  63. biodex-1.0.1/pyproject.toml +168 -0
  64. biodex-1.0.1/pytest.ini +6 -0
  65. biodex-1.0.1/requirements-base.txt +18 -0
  66. biodex-1.0.1/requirements-ci-core.txt +12 -0
  67. biodex-1.0.1/requirements-ci.txt +1 -0
  68. biodex-1.0.1/requirements.txt +19 -0
  69. biodex-1.0.1/run_biodex.bat +16 -0
  70. biodex-1.0.1/run_biodex.sh +17 -0
  71. biodex-1.0.1/scripts/__init__.py +1 -0
  72. biodex-1.0.1/scripts/batch_analyze.py +38 -0
  73. biodex-1.0.1/scripts/batch_smoke.py +231 -0
  74. biodex-1.0.1/scripts/build_desktop.ps1 +20 -0
  75. biodex-1.0.1/scripts/build_desktop.sh +27 -0
  76. biodex-1.0.1/scripts/demo_batch.py +520 -0
  77. biodex-1.0.1/scripts/fetch_examples.py +72 -0
  78. biodex-1.0.1/scripts/install_biodex.ps1 +34 -0
  79. biodex-1.0.1/scripts/install_biodex.sh +32 -0
  80. biodex-1.0.1/scripts/runpod_baseline.sh +29 -0
  81. biodex-1.0.1/scripts/runpod_diagnostics.sh +29 -0
  82. biodex-1.0.1/scripts/runpod_go.sh +20 -0
  83. biodex-1.0.1/scripts/runpod_install.sh +15 -0
  84. biodex-1.0.1/scripts/runpod_setup.sh +36 -0
  85. biodex-1.0.1/scripts/runpod_verify.sh +52 -0
  86. biodex-1.0.1/scripts/setup.bat +26 -0
  87. biodex-1.0.1/scripts/setup.sh +49 -0
  88. biodex-1.0.1/scripts/setup_gpu.sh +16 -0
  89. biodex-1.0.1/scripts/smoke_test.py +134 -0
  90. biodex-1.0.1/scripts/test_mega_load.py +19 -0
  91. biodex-1.0.1/tests/test_analytics.py +35 -0
  92. biodex-1.0.1/tests/test_batch.py +66 -0
  93. biodex-1.0.1/tests/test_batch_chunking.py +49 -0
  94. biodex-1.0.1/tests/test_batch_report.py +50 -0
  95. biodex-1.0.1/tests/test_batch_smoke.py +167 -0
  96. biodex-1.0.1/tests/test_classifier.py +86 -0
  97. biodex-1.0.1/tests/test_cli.py +132 -0
  98. biodex-1.0.1/tests/test_config.py +41 -0
  99. biodex-1.0.1/tests/test_demo_batch.py +155 -0
  100. biodex-1.0.1/tests/test_desktop.py +64 -0
  101. biodex-1.0.1/tests/test_detector.py +253 -0
  102. biodex-1.0.1/tests/test_exports.py +147 -0
  103. biodex-1.0.1/tests/test_exports_formats.py +78 -0
  104. biodex-1.0.1/tests/test_models_registry.py +65 -0
  105. biodex-1.0.1/tests/test_quick_demo.py +90 -0
  106. biodex-1.0.1/tests/test_types.py +51 -0
  107. biodex-1.0.1/tests/test_video.py +47 -0
  108. biodex-1.0.1/tests/test_visualization.py +77 -0
  109. biodex-1.0.1/ui/__init__.py +1 -0
  110. biodex-1.0.1/ui/api_menu.py +73 -0
  111. biodex-1.0.1/ui/components.py +543 -0
  112. biodex-1.0.1/ui/favicon.png +0 -0
  113. biodex-1.0.1/ui/handlers.py +759 -0
  114. biodex-1.0.1/ui/llm_review.py +142 -0
  115. biodex-1.0.1/ui/llm_settings.py +555 -0
  116. biodex-1.0.1/ui/settings_store.py +46 -0
  117. biodex-1.0.1/ui/styles.py +1389 -0
  118. biodex-1.0.1/ui/tabs.py +205 -0
  119. biodex-1.0.1/ui/tree_of_life_background.avif +0 -0
  120. biodex-1.0.1/ui/tree_of_life_background.jpg +0 -0
@@ -0,0 +1,75 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install test dependencies
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -r requirements-ci.txt
28
+
29
+ - name: Run unit tests
30
+ run: pytest tests/ -v -m "not slow"
31
+
32
+ - name: Verify Gradio app builds
33
+ run: python -c "from app import build_app; build_app(); print('app ok')"
34
+
35
+ lint:
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v4
39
+
40
+ - name: Set up Python
41
+ uses: actions/setup-python@v5
42
+ with:
43
+ python-version: "3.11"
44
+
45
+ - name: Install lint dependencies
46
+ run: |
47
+ python -m pip install --upgrade pip
48
+ pip install -r requirements-ci.txt
49
+
50
+ - name: Ruff
51
+ run: ruff check core app.py ui desktop tests
52
+
53
+ - name: Mypy
54
+ run: mypy core app.py ui
55
+
56
+ - name: Pre-commit (all files)
57
+ run: |
58
+ pip install pre-commit
59
+ pre-commit run --all-files
60
+
61
+ build:
62
+ runs-on: ubuntu-latest
63
+ steps:
64
+ - uses: actions/checkout@v4
65
+
66
+ - name: Set up Python
67
+ uses: actions/setup-python@v5
68
+ with:
69
+ python-version: "3.11"
70
+
71
+ - name: Build package artifacts
72
+ run: |
73
+ python -m pip install --upgrade pip
74
+ pip install build
75
+ python -m build
@@ -0,0 +1,77 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: "3.11"
20
+
21
+ - name: Install build tools
22
+ run: pip install build hatchling
23
+
24
+ - name: Build wheel and sdist
25
+ run: python -m build
26
+
27
+ - name: Verify package metadata
28
+ run: |
29
+ pip install twine
30
+ twine check dist/*
31
+
32
+ - name: Upload release artifacts
33
+ uses: actions/upload-artifact@v4
34
+ with:
35
+ name: dist
36
+ path: dist/
37
+
38
+ github-release:
39
+ needs: build
40
+ runs-on: ubuntu-latest
41
+ permissions:
42
+ contents: write
43
+ steps:
44
+ - uses: actions/download-artifact@v4
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+
49
+ - name: Attach build artifacts to GitHub Release
50
+ uses: softprops/action-gh-release@v2
51
+ with:
52
+ files: dist/*
53
+ generate_release_notes: false
54
+ fail_on_unmatched_files: true
55
+
56
+ publish:
57
+ needs: build
58
+ runs-on: ubuntu-latest
59
+ # Trusted Publishing must be configured on PyPI before enabling this job:
60
+ # https://pypi.org/manage/project/biodex/settings/publishing/ (see docs/publishing.md)
61
+ # This job stays SKIPPED (not failed) until you set the repository variable
62
+ # PYPI_PUBLISH = true (Settings -> Secrets and variables -> Actions -> Variables)
63
+ # so release runs are green out of the box.
64
+ if: startsWith(github.ref, 'refs/tags/v') && vars.PYPI_PUBLISH == 'true'
65
+ environment: pypi
66
+ permissions:
67
+ id-token: write
68
+ steps:
69
+ - uses: actions/download-artifact@v4
70
+ with:
71
+ name: dist
72
+ path: dist/
73
+
74
+ - uses: pypa/gh-action-pypi-publish@release/v1
75
+ with:
76
+ packages-dir: dist/
77
+ skip-existing: true
@@ -0,0 +1,72 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ *.egg-info/
20
+ .installed.cfg
21
+ *.egg
22
+
23
+ # Virtual environments
24
+ .venv/
25
+ venv/
26
+ ENV/
27
+ env/
28
+
29
+ # Gradio
30
+ .gradio/
31
+ flagged/
32
+
33
+ # IDE / editor
34
+ .idea/
35
+ .vscode/
36
+ *.swp
37
+ *.swo
38
+ *~
39
+
40
+ # OS
41
+ .DS_Store
42
+ Thumbs.db
43
+ desktop.ini
44
+
45
+ # Model weights and caches (downloaded on first run)
46
+ *.pt
47
+ *.pth
48
+ *.onnx
49
+ megadetector/
50
+ md_v5a*
51
+ .cache/
52
+ torch_cache/
53
+
54
+ # Temp exports
55
+ biodex_annotated_*
56
+ biodex_detections_*
57
+
58
+ # Logs
59
+ *.log
60
+
61
+ # Test outputs
62
+ outputs/
63
+ results/
64
+ .pytest_cache/
65
+ .mypy_cache/
66
+ .ruff_cache/
67
+
68
+ # Sync / build tarballs and transient working dirs
69
+ *.tar
70
+ demo/
71
+ deploy/
72
+ utils/
@@ -0,0 +1,17 @@
1
+ # See https://pre-commit.com for more information
2
+ repos:
3
+ - repo: https://github.com/astral-sh/ruff-pre-commit
4
+ rev: v0.8.4
5
+ hooks:
6
+ - id: ruff
7
+ args: [--fix]
8
+ files: ^(core|ui|desktop|tests|app\.py)/
9
+ - repo: https://github.com/pre-commit/mirrors-mypy
10
+ rev: v1.13.0
11
+ hooks:
12
+ - id: mypy
13
+ additional_dependencies:
14
+ - types-Pillow
15
+ - pandas-stubs
16
+ args: [core, app.py, ui]
17
+ pass_filenames: false
@@ -0,0 +1,80 @@
1
+ # Changelog
2
+
3
+ All notable changes to BioDex are documented here.
4
+
5
+ ## [1.0.1] — 2026-06-09
6
+
7
+ ### Added
8
+
9
+ - **Optional AI review (BYOK)** — footer **Use via API** menu with provider/model/key storage; **AI review (LLM)** on batch frame review (scene summary, species second opinion, data-quality flags)
10
+ - LLM modules: `ui/llm_settings.py`, `ui/llm_review.py`, `ui/api_menu.py`
11
+ - Brand assets under `docs/` and savanna background for the field-review UI
12
+
13
+ ### Changed
14
+
15
+ - UI polish: compact footer/API menu, analytics contrast, hidden broken dataframe toolbar buttons
16
+ - README and SECURITY updated for current feature set (removed outdated dark-mode references; documented BYOK key storage)
17
+ - Model catalog labels note custom model IDs are supported
18
+
19
+ ### Fixed
20
+
21
+ - OpenAI GPT-5 / o-series test and generation requests use `max_completion_tokens` where required
22
+ - Ruff lint (`page_column` unused binding in `app.py`)
23
+
24
+ ### Known limitations
25
+
26
+ - LLM review is optional BYOK and limited to batch frame review in this release
27
+ - Model dropdown slugs are provider-specific; not all entries are validated against live APIs
28
+ - API keys stored as plain text in `~/.cache/biodex/settings.json` (documented in SECURITY.md)
29
+
30
+ ## [1.0.0] — 2026-06-08
31
+
32
+ ### Added
33
+
34
+ - General-availability release line for BioDex with local-first camera-trap analysis workflows
35
+ - Stable tabbed UI workflow (Dashboard, Batch, Video, Analytics, Settings) and export pipeline coverage
36
+ - Production packaging path (CPU/GPU Dockerfiles, release workflow, pre-commit hooks)
37
+
38
+ ### Changed
39
+
40
+ - Version bumped from `0.5.0` to `1.0.0` in runtime metadata and release documentation
41
+ - Roadmap and README updated to reflect a v1 baseline and post-1.0 planning
42
+
43
+ ### Reliability
44
+
45
+ - Full quality gates pass: pytest (`not slow`), ruff, mypy (`core`, `app.py`, `ui`), and `build_app()` smoke check
46
+ - Default behavior remains backwards-compatible (`MDV5A` detector + optional SpeciesNet classification)
47
+ - CI/release hardening: package build job, pre-commit checks in CI, and Docker health checks
48
+ - Added release documentation artifacts: `CITATION.cff`, `CONTRIBUTING.md`, `SECURITY.md`
49
+
50
+ ## [0.5.0] — 2025-06-08
51
+
52
+ ### Added
53
+
54
+ - **Pluggable model architecture** — `core/models/` registry with MegaDetector and SpeciesNet adapters; edge ONNX/TensorRT stubs
55
+ - **ModelSettings** — env-driven config (`BIODEX_DETECTOR_MODEL`, `BIODEX_TORCH_COMPILE`, `BIODEX_GEOFENCE_REGION`, etc.)
56
+ - **Batch performance** — chunking, cancel event, I/O workers, ETA progress (`core/progress.py`)
57
+ - **Video foundations** — `core/video.py` frame extraction, `VideoResult`, `biodex video` CLI (requires `[video]` extra)
58
+ - **Advanced exports** — Wildlife Insights CSV, iNaturalist drafts, timelapse JSON, SQLite, EcoSentinel hook
59
+ - **Analytics** — diversity index, activity heatmap (`[analytics]` extra)
60
+ - **Audit log stub** — opt-in hash-chained JSONL (`BIODEX_AUDIT_LOG=1`)
61
+ - **EXIF/GPS** — `core/exif_utils.py` for export metadata and geofencing fallback
62
+ - **Tabbed UI** — Dashboard, Batch, Video, Analytics, Settings tabs with dark mode and cancel button
63
+ - **Packaging** — Dockerfile (CPU/GPU), release workflow, pre-commit hooks
64
+ - **Optional extras** — `video`, `analytics`, `edge`, `all`
65
+
66
+ ### Changed
67
+
68
+ - `detector.py` and `classifier.py` refactored as thin facades over the model registry
69
+ - CLI adds `--chunk-size`, `--workers`, `--torch-compile`
70
+ - JSON exports include `human_review` and `review_notes` fields
71
+ - `BatchResult.interrupted` flag for cancelled runs
72
+
73
+ ### Backwards compatibility
74
+
75
+ - All symbols in `core/__init__.py` remain importable with identical default behavior (MDV5A + SpeciesNet)
76
+ - `build_app()` and `launch_app()` signatures unchanged
77
+
78
+ ## [0.4.x] — prior releases
79
+
80
+ See git history for v0.4 batch CLI, species tiers, and field-review UI.
@@ -0,0 +1,14 @@
1
+ cff-version: 1.2.0
2
+ title: BioDex
3
+ message: "If you use BioDex in research, please cite this software."
4
+ type: software
5
+ authors:
6
+ - family-names: FratresMedAI
7
+ given-names: Team
8
+ repository-code: "https://github.com/FratresMedAI/BioDex"
9
+ license: MIT
10
+ version: "1.0.1"
11
+ date-released: 2026-06-08
12
+ abstract: >
13
+ BioDex is a local-first wildlife camera-trap analysis tool using MegaDetector
14
+ and optional SpeciesNet classification, with export formats for conservation workflows.
@@ -0,0 +1,33 @@
1
+ # Contributing to BioDex
2
+
3
+ Thanks for helping improve BioDex.
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ pip install -e ".[ui,models,dev]"
9
+ pre-commit install
10
+ ```
11
+
12
+ ## Quality gates (must pass)
13
+
14
+ ```bash
15
+ ruff check core app.py ui desktop tests
16
+ mypy core app.py ui
17
+ pytest tests/ -v -m "not slow"
18
+ python -c "from app import build_app; build_app(); print('app ok')"
19
+ ```
20
+
21
+ ## Scope and standards
22
+
23
+ - Keep BioDex local-first and privacy-preserving by default.
24
+ - Preserve public API compatibility (`core/__init__.py`, CLI behavior, `build_app()` / `launch_app()`).
25
+ - Add/maintain docstrings and explicit error handling.
26
+ - Include tests for behavior changes.
27
+
28
+ ## Pull request checklist
29
+
30
+ - [ ] Added or updated tests
31
+ - [ ] Updated docs/CHANGELOG when user-facing behavior changed
32
+ - [ ] Ran all quality gates locally
33
+ - [ ] Avoided unrelated refactors
@@ -0,0 +1,39 @@
1
+ # BioDex CPU Docker image
2
+ FROM python:3.11-slim AS runtime
3
+
4
+ LABEL org.opencontainers.image.title="BioDex" \
5
+ org.opencontainers.image.description="Local-first wildlife camera trap AI analysis (CPU)" \
6
+ org.opencontainers.image.licenses="MIT"
7
+
8
+ WORKDIR /app
9
+
10
+ RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ libgl1 \
12
+ libglib2.0-0 \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ COPY pyproject.toml README.md constraints.txt ./
16
+ COPY core ./core
17
+ COPY ui ./ui
18
+ COPY biodex ./biodex
19
+ COPY app.py ./
20
+
21
+ # Models install order mirrors scripts/install_biodex.sh to avoid the
22
+ # megadetector/speciesnet protobuf + onnx ResolutionImpossible. CPU torch is
23
+ # installed before megadetector so its torch dependency is already satisfied
24
+ # (keeps the multi-GB CUDA wheels out of the CPU image).
25
+ RUN pip install --no-cache-dir --upgrade pip wheel \
26
+ && pip install --no-cache-dir "protobuf==3.20.1" \
27
+ && pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu \
28
+ && pip install --no-cache-dir "megadetector>=10.0,<11.0" \
29
+ && pip install --no-cache-dir "Pillow>=9.5" "numpy>=1.26.4,<2.0" "pandas>=2.1" "tqdm>=4.64" "setuptools>=65.0,<81.0" \
30
+ && (pip install --no-cache-dir "speciesnet>=5.0,<6.0" || pip install --no-cache-dir "speciesnet>=5.0,<6.0" --no-deps) \
31
+ && pip install --no-cache-dir ".[ui,video]" \
32
+ && pip install --no-cache-dir "protobuf==3.20.1" --force-reinstall
33
+
34
+ EXPOSE 7860
35
+ ENV BIODEX_HOST=0.0.0.0 BIODEX_DEPLOY=1
36
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
37
+ CMD python -c "import socket; s=socket.socket(); s.settimeout(3); s.connect(('127.0.0.1',7860)); s.close()"
38
+
39
+ CMD ["biodex-ui"]
@@ -0,0 +1,38 @@
1
+ # BioDex GPU Docker image (CUDA runtime + PyTorch GPU wheels)
2
+ FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
3
+
4
+ LABEL org.opencontainers.image.title="BioDex" \
5
+ org.opencontainers.image.description="Local-first wildlife camera trap AI analysis (GPU)" \
6
+ org.opencontainers.image.licenses="MIT"
7
+
8
+ ENV DEBIAN_FRONTEND=noninteractive
9
+ RUN apt-get update && apt-get install -y --no-install-recommends \
10
+ python3 python3-pip python3-venv \
11
+ libgl1 libglib2.0-0 \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ WORKDIR /app
15
+ COPY pyproject.toml README.md constraints.txt ./
16
+ COPY core ./core
17
+ COPY ui ./ui
18
+ COPY biodex ./biodex
19
+ COPY app.py ./
20
+
21
+ # Models install order mirrors scripts/install_biodex.sh to avoid the
22
+ # megadetector/speciesnet protobuf + onnx ResolutionImpossible. CUDA torch is
23
+ # installed before megadetector so its torch dependency is already satisfied.
24
+ RUN pip3 install --no-cache-dir --upgrade pip wheel \
25
+ && pip3 install --no-cache-dir "protobuf==3.20.1" \
26
+ && pip3 install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cu121 \
27
+ && pip3 install --no-cache-dir "megadetector>=10.0,<11.0" \
28
+ && pip3 install --no-cache-dir "Pillow>=9.5" "numpy>=1.26.4,<2.0" "pandas>=2.1" "tqdm>=4.64" "setuptools>=65.0,<81.0" \
29
+ && (pip3 install --no-cache-dir "speciesnet>=5.0,<6.0" || pip3 install --no-cache-dir "speciesnet>=5.0,<6.0" --no-deps) \
30
+ && pip3 install --no-cache-dir ".[ui,video]" \
31
+ && pip3 install --no-cache-dir "protobuf==3.20.1" --force-reinstall
32
+
33
+ EXPOSE 7860
34
+ ENV BIODEX_HOST=0.0.0.0 BIODEX_DEPLOY=1
35
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
36
+ CMD python3 -c "import socket; s=socket.socket(); s.settimeout(3); s.connect(('127.0.0.1',7860)); s.close()"
37
+
38
+ CMD ["biodex-ui"]
biodex-1.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BioDex Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
biodex-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.4
2
+ Name: biodex
3
+ Version: 1.0.1
4
+ Summary: Local, privacy-first AI for wildlife camera trap analysis and conservation monitoring
5
+ Author: FratresMedAI
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: biodiversity,camera-trap,conservation,defensive-monitoring,megadetector,speciesnet,wildlife,wildlife-insights
9
+ Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
20
+ Requires-Python: <3.13,>=3.10
21
+ Requires-Dist: numpy<2.0,>=1.26.4
22
+ Requires-Dist: pandas>=2.1
23
+ Requires-Dist: pillow>=9.5
24
+ Requires-Dist: setuptools<81.0,>=65.0
25
+ Requires-Dist: tqdm>=4.64
26
+ Requires-Dist: typer>=0.12
27
+ Provides-Extra: all
28
+ Requires-Dist: gradio<7.0,>=5.0; extra == 'all'
29
+ Requires-Dist: matplotlib>=3.7; extra == 'all'
30
+ Requires-Dist: megadetector<11.0,>=10.0; extra == 'all'
31
+ Requires-Dist: mypy>=1.10; extra == 'all'
32
+ Requires-Dist: onnxruntime>=1.16; extra == 'all'
33
+ Requires-Dist: opencv-python-headless>=4.8; extra == 'all'
34
+ Requires-Dist: pyinstaller>=6.0; extra == 'all'
35
+ Requires-Dist: pytest>=8.0; extra == 'all'
36
+ Requires-Dist: ruff>=0.4; extra == 'all'
37
+ Requires-Dist: seaborn>=0.13; extra == 'all'
38
+ Requires-Dist: speciesnet<6.0,>=5.0; extra == 'all'
39
+ Requires-Dist: torch>=2.0; extra == 'all'
40
+ Requires-Dist: types-pillow; extra == 'all'
41
+ Provides-Extra: analytics
42
+ Requires-Dist: matplotlib>=3.7; extra == 'analytics'
43
+ Requires-Dist: seaborn>=0.13; extra == 'analytics'
44
+ Provides-Extra: desktop
45
+ Requires-Dist: pyinstaller>=6.0; extra == 'desktop'
46
+ Provides-Extra: dev
47
+ Requires-Dist: mypy>=1.10; extra == 'dev'
48
+ Requires-Dist: pytest>=8.0; extra == 'dev'
49
+ Requires-Dist: ruff>=0.4; extra == 'dev'
50
+ Requires-Dist: types-pillow; extra == 'dev'
51
+ Provides-Extra: edge
52
+ Requires-Dist: onnxruntime>=1.16; (platform_system != 'Darwin' or platform_machine != 'arm64') and extra == 'edge'
53
+ Provides-Extra: models
54
+ Requires-Dist: megadetector<11.0,>=10.0; extra == 'models'
55
+ Requires-Dist: speciesnet<6.0,>=5.0; extra == 'models'
56
+ Requires-Dist: torch>=2.0; extra == 'models'
57
+ Provides-Extra: ui
58
+ Requires-Dist: gradio<7.0,>=5.0; extra == 'ui'
59
+ Provides-Extra: video
60
+ Requires-Dist: opencv-python-headless>=4.8; extra == 'video'
61
+ Description-Content-Type: text/markdown
62
+
63
+ # BioDex
64
+
65
+ **Local AI for wildlife camera traps.** Detect animals, filter blanks, identify species, export results — on your machine, not in the cloud.
66
+
67
+ [![Python 3.10–3.12](https://img.shields.io/badge/python-3.10--3.12-blue.svg)](https://www.python.org/)
68
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
69
+ [![Version](https://img.shields.io/badge/version-1.0.1-brightgreen.svg)](CHANGELOG.md)
70
+ [![CI](https://github.com/FratresMedAI/BioDex/actions/workflows/ci.yml/badge.svg)](https://github.com/FratresMedAI/BioDex/actions/workflows/ci.yml)
71
+ [![Release](https://github.com/FratresMedAI/BioDex/actions/workflows/release.yml/badge.svg)](https://github.com/FratresMedAI/BioDex/actions/workflows/release.yml)
72
+
73
+ Built for conservation research, field review, and defensive wildlife monitoring (Fratres / EcoSentinel integration hooks).
74
+
75
+ ---
76
+
77
+ ## Run locally (do this)
78
+
79
+ **Mac / Linux**
80
+
81
+ ```bash
82
+ git clone https://github.com/FratresMedAI/BioDex.git
83
+ cd BioDex
84
+ ./run_biodex.sh
85
+ ```
86
+
87
+ **Windows**
88
+
89
+ ```bat
90
+ git clone https://github.com/FratresMedAI/BioDex.git
91
+ cd BioDex
92
+ run_biodex.bat
93
+ ```
94
+
95
+ Your browser opens **http://127.0.0.1:7860**. Use the **Batch** tab to process a folder, or **Quick demo** for a fast preview.
96
+
97
+ First analysis downloads models once (~500 MB). After that, everything stays offline on your computer.
98
+
99
+ ---
100
+
101
+ ## v1.0 highlights
102
+
103
+ - **Pluggable models** — registry architecture (`core/models/`) with MegaDetector + SpeciesNet adapters
104
+ - **Batch performance** — chunking, cancel, ETA progress, optional `torch.compile`
105
+ - **Video foundations** — frame sampling + timeline export (`biodex video`, requires `[video]` extra)
106
+ - **Advanced exports** — Wildlife Insights, iNaturalist drafts, timelapse JSON, SQLite, EcoSentinel hook
107
+ - **Tabbed UI** — Dashboard, Batch, Video, Analytics, Settings
108
+ - **Optional AI review (BYOK)** — per-frame LLM notes after batch runs (see below)
109
+ - **Docker** — CPU and GPU images for deployment
110
+ - **Release maturity** — stable API surface, strict typing/linting, and CI-gated quality
111
+
112
+ ---
113
+
114
+ ## Optional AI review (BYOK)
115
+
116
+ Core detection runs **fully offline** on your machine. AI review is an **optional** power feature:
117
+
118
+ 1. Open **Use via API** in the footer.
119
+ 2. Choose a provider, paste your API key, pick a model (or type a custom model ID), then **Save**.
120
+ 3. After a batch run, select a frame and click **AI review (LLM)** for a field note: scene summary, species second opinion, and data-quality flags.
121
+
122
+ **Privacy:** API keys are stored locally in `~/.cache/biodex/settings.json` and sent only to the provider you choose — never to BioDex servers. See [SECURITY.md](SECURITY.md).
123
+
124
+ **Scope in v1.0.1:** batch frame review only. Single-image spot check, video key frames, and batch-level summaries are planned for v1.1. Not every model slug in the dropdown is guaranteed to work with every provider — use a custom model ID if needed.
125
+
126
+ ---
127
+
128
+ ## Extras install matrix
129
+
130
+ ```bash
131
+ pip install -e ".[ui,models]" # Web UI + inference (default)
132
+ pip install -e ".[video]" # OpenCV video support
133
+ pip install -e ".[analytics]" # Heatmaps + diversity metrics
134
+ pip install -e ".[edge]" # ONNX stubs (future edge deploy)
135
+ pip install -e ".[all]" # Everything
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Batch CLI
141
+
142
+ For large folders (100+ images), no browser:
143
+
144
+ ```bash
145
+ biodex batch /path/to/images -o ./results --classify-species --recursive
146
+ biodex batch /path/to/images -o ./results --chunk-size 500 --torch-compile
147
+ biodex video /path/to/clip.mp4 -o ./video-results --fps 1 --max-frames 120
148
+ ```
149
+
150
+ Environment variables: `BIODEX_DETECTOR_MODEL`, `BIODEX_TORCH_COMPILE`, `BIODEX_GEOFENCE_REGION`, `BIODEX_AUDIT_LOG=1`
151
+
152
+ ## Docker quick start
153
+
154
+ ```bash
155
+ docker build -t biodex:cpu -f Dockerfile .
156
+ docker run --rm -p 7860:7860 biodex:cpu
157
+ ```
158
+
159
+ GPU:
160
+
161
+ ```bash
162
+ docker build -t biodex:gpu -f Dockerfile.gpu .
163
+ ```
164
+
165
+ ---
166
+
167
+ ## Developers
168
+
169
+ ```bash
170
+ pip install -e ".[ui,models,dev]"
171
+ pytest tests/ -v -m "not slow"
172
+ ruff check core app.py ui
173
+ mypy core app.py ui
174
+ pre-commit install # optional
175
+ ```
176
+
177
+ See [CHANGELOG.md](CHANGELOG.md), [docs/roadmap.md](docs/roadmap.md), [CONTRIBUTING.md](CONTRIBUTING.md), and [SECURITY.md](SECURITY.md).
178
+
179
+ ---
180
+
181
+ MIT License. Uses [MegaDetector](https://github.com/agentmorris/MegaDetector) and [SpeciesNet](https://github.com/google/cameratrapai).