|
1 | | -- Use PyQt6 for GUI. |
2 | | -- Split code into files when possible. |
3 | | -- Make code clean and understandable. |
4 | | -- Optimize code for performance and memory usage. |
| 1 | +# anylabeling — guidance for AI assistants |
| 2 | + |
| 3 | +This is a desktop image-annotation app on PyQt6, with an auto-labeling |
| 4 | +backend that runs ONNX models (YOLOv5/v8, SAM1/MobileSAM, SAM2, SAM3) |
| 5 | +and a CoreML path for SAM2 on macOS. PyPI ships two parallel packages |
| 6 | +from the same source tree: `anylabeling` (CPU, default) and |
| 7 | +`anylabeling-gpu` (Linux/Windows, swaps in `onnxruntime-gpu`). |
| 8 | + |
| 9 | +## Conventions |
| 10 | +- Use **PyQt6** (not PyQt5). The migration happened in commit 9735fe8. |
| 11 | +- The macOS install path **excludes PyQt6** from `pyproject.toml` |
| 12 | + (`platform_system != 'Darwin'`); macOS users get it via conda. |
| 13 | + Don't add a Darwin-side floor without changing the install story. |
| 14 | +- Keep code split into focused files; avoid growing `label_widget.py` |
| 15 | + (already ~3.2k LOC) further when a new widget would do. |
| 16 | + |
| 17 | +## Architecture cheat sheet |
| 18 | +- Entry point: `anylabeling/app.py` → `MainWindow` → `LabelingWrapper` → |
| 19 | + `LabelingWidget` (the "god widget" — owns canvas, file list, toolbars). |
| 20 | +- Auto-labeling: `anylabeling/services/auto_labeling/` |
| 21 | + - `registry.py` → `@ModelRegistry.register("type-name")` decorator |
| 22 | + - `model_manager.py` → loads `models.yaml`, downloads weights to |
| 23 | + `~/anylabeling_data/models/`, dispatches `predict_shapes_threading()` |
| 24 | + - `models.yaml` (`anylabeling/configs/auto_labeling/`) is the model |
| 25 | + catalog the UI reads. New model = new entry **and** registered class. |
| 26 | + - `segment_anything.py` auto-detects SAM1/SAM2/SAM3 from ONNX inputs. |
| 27 | +- CPU/GPU duality: `setup.py` reads `__preferred_device__` from |
| 28 | + `anylabeling/app_info.py`; publish workflows `sed` it before `python -m build`. |
| 29 | + |
| 30 | +## Pre-publish gate |
| 31 | +- `.github/workflows/tests.yml` runs a 9-cell matrix (Ubuntu/Windows/macOS |
| 32 | + × py3.11/3.12/3.13). All publish/release workflows declare `needs: test`. |
| 33 | +- Why it exists: `anylabeling-gpu==0.4.30` shipped to PyPI broken because |
| 34 | + no automated step ran `pip install .` against current dep floors before |
| 35 | + publish (issue #227, `imgviz>=2.0` returned a read-only colormap). |
| 36 | +- Always run `python -m unittest discover -s tests` in a fresh venv before |
| 37 | + tagging a release. See `CLAUDE.md` for the full pre-publish playbook. |
| 38 | + |
| 39 | +## Resource regeneration |
| 40 | +- PyQt6 dropped `pyrcc`. To rebuild `anylabeling/resources/resources.py` |
| 41 | + use `python scripts/compile_languages.py` — it shells out to |
| 42 | + `pyside6-rcc` and `pyside6-lrelease` and rewrites imports back to PyQt6. |
| 43 | +- `PySide6-Essentials` is a `[dev]` extra for this reason only; runtime |
| 44 | + has no PySide6 dependency. |
0 commit comments