A temporal computer vision system designed to help gastroenterologists detect missed polyps during colonoscopy by analyzing video context rather than just single frames.
Status: Verified via Simulation (Training Pipeline & Fusion Logic Operational)
The following diagram illustrates the dual-path architecture designed to minimize false negatives (missed polyps) while preventing false positives (flickering alerts) that cause alarm fatigue.
flowchart TD
VideoInput[Video Stream Input] --> Backbone[ResNet+FPN Backbone]
subgraph SpatialPath [Spatial Intelligence]
Backbone -->|Frame Features| RetinaHead[RetinaNet Head]
RetinaHead -->|Box & Class| RawDetections[Raw Frame Detections]
end
subgraph TemporalPath [Temporal Intelligence]
Backbone -->|Feature Sequence| ConvGRU[ConvGRU Memory Module]
ConvGRU -->|Refined Features| TemporalHead[Temporal Head]
TemporalHead -->|Context-Aware Box| TemporalDetections[Temporal Detections]
ConvGRU -.->|State t-1| ConvGRU
end
RawDetections --> Fusion[Fusion Engine]
TemporalDetections --> Fusion
subgraph ClinicalFusion [Clinical Decision Support]
Fusion -->|Check Consistency| HistoryBuffer[History Buffer]
HistoryBuffer -->|Stable?| AlertLogic{Alert Decision}
AlertLogic -->|Yes| ClinicianAlert[High Confidence Alert]
AlertLogic -->|No| LowPriority[Background Log]
end
subgraph Explainability
TemporalHead -->|Activations| AttentionMap[Attention Heatmap]
AttentionMap --> ClinicianOverlay[Clinician Overlay]
end
style SpatialPath fill:#e1f5fe,stroke:#01579b
style TemporalPath fill:#fff3e0,stroke:#ff6f00
style ClinicalFusion fill:#e8f5e9,stroke:#2e7d32
style Explainability fill:#f3e5f5,stroke:#7b1fa2
- Temporal Consistency: Uses LSTM/ConvRNN modules to remember polyp locations across frames, handling motion blur and temporary occlusions.
- Dual-Path Architecture:
- Spatial Path: RetinaNet (ResNet+FPN) for high-precision frame analysis.
- Temporal Path: Aggregates features over time to boost confidence for fleeting objects.
- Clinical Fusion Engine: Smart logic to filter alerts, ensuring the doctor is notified only when detections are stable, preventing "alert fatigue."
- Explainability: Real-time Attention Maps overlay to show where the model is looking.
elusive-polyps-detection/
├── data/
│ ├── dataset_loader.py # CVC-ClinicDB / Kvasir loaders
│ └── sequence_generator.py # Synthesizes video motion from static images
├── detectors/
│ ├── backbone.py # ResNet + FPN
│ ├── retinanet.py # Single-frame detector head
│ ├── temporal_model.py # LSTM-based sequence refiner
│ └── loss.py # Focal Loss for class imbalance
├── fusion/
│ └── fusion_engine.py # Logic for stable alerts
├── inference/
│ └── stream_simulator.py # Real-time simulation demo
├── training/
│ └── train.py # Full training loop
└── utils/
└── explainability.py # Attention map generation
pip install -r requirements.txtThis runs the entire pipeline (Dual-Path + Fusion + Explainability) on a synthetic video stream.
python inference/stream_simulator.pyExpected Output: A window or console log showing specific frames where the Fusion Engine stabilizes alerts ("CONFIRMED") despite simulated raw detection flickering.
To train the model (default: synthetic data loop):
python training/train.pyWe have verified the core logic of the system:
- Dual-Path Architecture:
- Built a RetinaNet (ResNet+FPN) for high-quality spatial detection.
- Built a Temporal Module (ConvGRU) to aggregate features across video frames.
- Dataset Flexibility:
- Implemented a
SyntheticSequenceGeneratorthat allows training/testing the temporal model using static datasets (like CVC-ClinicDB) by simulating realistic endoscope motion.
- Implemented a
- Clinical Fusion Logic:
- Implemented
FusionEnginewhich successfully reinforces persistent detections and filters out transient noise.
- Implemented
- Training Verification:
- Successfully executed the training loop with Focal Loss and Anchor Matching.
- Log:
Batch 0, Loss: 15176...confirming backward pass integrity.
- Download real video data (LDPolypVideo).
- Train the spatial RetinaNet on CVC-ClinicDB.
- Fine-tune the temporal module on video sequences.