ai-cfia / ai-cfia/nachet

FastAPI served model: EigenGradCAM explainability for the Swin 101spp classifier

Ouverte
#888 0 commentaires 0 réactions 1 personne assignée Réclamée par @danilo-bukvic Voir sur GitHub
model nachet
Langage dominant
Python
Étoiles
2
Forks
2
Merge moyen
5 j 6 h
PR mergées (30 j)
5

Description

## Context

This issue adds a FastAPI endpoint serving EigenGradCAM explainability for the Swin
101spp classifier, following the existing service pattern in `environments/fastapi/`.
It is the server-side counterpart to the browser CAM already shipped in nachet-mini.

## Tasks

### Service scaffold
- [ ] Scaffold `environments/fastapi/classifier/swin-101spp-/` from the 27spp template
- [ ] Switch to `SwinForImageClassification` (101spp is v1, not v2)
- [ ] Document weight provisioning (`*.safetensors` is gitignored)
- [ ] Allocate a host port (28100 taken)

### CAM
- [ ] Add `grad-cam` + `ttach` deps
- [ ] Port `reshape_transform` + `HFLogits` from the notebook
- [ ] EigenGradCAM on `swin.layernorm`
- [ ] Keep the CAM call outside `torch.no_grad()`

### API
- [ ] `POST /v2/models//infer` → predictions + per-class CAM
- [ ] Pick response format: raw 12×12 grid vs overlay PNG
- [ ] Top-K parameter
- [ ] Health endpoints (`/v2/health/ready`, `/v2/health/live`)

### Container
- [ ] Dockerfile + `compose.yaml` with GPU reservation and healthcheck
- [ ] CPU fallback for dev machines

### Validation
- [ ] Per-map cosine similarity vs notebook output
- [ ] Latency + VRAM (backward pass ~doubles memory)
- [ ] Thread-safety of CAM hooks under concurrent requests

### Docs
- [ ] Service README + `curl` example

## Open questions

1. Server would render EigenGradCAM, browser renders exact linear-head CAM — same
seed, different heatmaps across surfaces. Intended, or should they match?

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.