fix: replace parallel edge syntax in Mermaid diagram #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.9", "3.10", "3.11"] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: | | ||
| pip install --upgrade pip | ||
| pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu | ||
| pip install numpy matplotlib pytest | ||
| - name: Test ObjectDetector architecture | ||
| run: python -c " | ||
| import torch, sys | ||
| sys.path.insert(0, '.') | ||
| from models.detector import ObjectDetector | ||
| model = ObjectDetector(num_classes=20, backbone='resnet18', pretrained=False, | ||
| num_anchors=5, grid_size=14) | ||
| x = torch.randn(2, 3, 448, 448) | ||
| out = model(x) | ||
| assert out.shape == (2, 14, 14, 5, 25), f'Wrong shape: {out.shape}' | ||
| # Check activations | ||
| assert (out[..., 0:2] >= 0).all() and (out[..., 0:2] <= 1).all(), 'xy out of [0,1]' | ||
| assert (out[..., 4] >= 0).all() and (out[..., 4] <= 1).all(), 'conf out of [0,1]' | ||
| params = model.get_num_parameters() | ||
| print(f'ObjectDetector OK | shape={out.shape} | params={params:,}') | ||
| " | ||
| - name: Test custom backbone | ||
| run: python -c " | ||
| import torch, sys | ||
| sys.path.insert(0, '.') | ||
| from models.detector import ObjectDetector | ||
| model = ObjectDetector(num_classes=20, backbone='custom', pretrained=False) | ||
| x = torch.randn(1, 3, 448, 448) | ||
| out = model(x) | ||
| assert out.shape[0] == 1, 'Batch size mismatch' | ||
| print(f'Custom backbone OK | output shape: {out.shape}') | ||
| " | ||
| - name: Lint (errors only) | ||
| run: | | ||
| pip install flake8 | ||
| flake8 models/ utils/ scripts/ --max-line-length=120 --select=E9,F63,F7,F82 | ||
| generate-plots: | ||
| runs-on: ubuntu-latest | ||
| needs: test | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
| - run: pip install numpy matplotlib | ||
| - run: python scripts/generate_detection_plots.py --out docs/images/ | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: detection-demo-plots | ||
| path: docs/images/ | ||
| retention-days: 30 | ||