# azamat1ch/rsna-knee-2nd-place architecture

> Architecture diagram of the GitHub repository azamat1ch/rsna-knee-2nd-place, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azamat1ch/rsna-knee-2nd-place
- Repository: https://github.com/azamat1ch/rsna-knee-2nd-place

## Overview

This repository implements a competition pipeline for detecting 12 knee MRI abnormalities. At inference, the prediction runner prepares and validates the deployment, runs four core model members and optional specialists, then produces a rank-weighted submission. The package also supports DICOM preprocessing, training, and report/image-derived labels; the external reader and PF specialist provide separate model paths. The README documents the prediction and blend workflow, while source excerpts show selected preprocessing and model-input details. Several training and inference components are unsampled, so their internal links are omitted where not evidenced.

Main entry points: [`knee/infer.py`](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/infer.py) (Core inference), [`predict.py`](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/predict.py) (Prediction runner), [`knee/tiles.py`](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/tiles.py) (Crop inputs), [`knee/windows.py`](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/windows.py) (Window inputs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["MRI inputs"]
  node_competition[("Competition data")]
end

subgraph group_core["Core inference"]
  node_runner["Prediction runner<br/>[predict.py]"]
  node_dicom["DICOM decoding<br/>[dicom.py]"]
  node_series["Series selection<br/>[series.py]"]
  node_centre["Knee centering<br/>[centre.py]"]
  node_tiles["Crop inputs<br/>[tiles.py]"]
  node_windows["Window inputs<br/>[windows.py]"]
  node_models["Core models<br/>[models.py]"]
  node_infer["Core inference<br/>[infer.py]"]
end

subgraph group_specialists["Specialist models"]
  node_external["Reader members<br/>[external.py]"]
  node_reader["Reader inference<br/>[infer_c.py]"]
  node_pf["PF specialist<br/>[kaggle_infer.py]"]
  node_native["PF native inputs<br/>[prepare_native.py]"]
end

subgraph group_labels["Labels and training"]
  node_labels["Label generation<br/>[labels.py]"]
  node_panels["Expert image panels<br/>[panels.py]"]
  node_stores[("Training stores<br/>[stores.py]")]
  node_training["Core training<br/>[train.py]"]
  node_pftraining["PF training<br/>[train.py]"]
  node_labelsdata[("Label tables")]
end

subgraph group_results["Prediction outputs"]
  node_blend["Rank blend<br/>[blend.py]"]
  node_submission["Submission output"]
end

node_competition -->|"provides exams"| node_runner
node_runner -->|"runs core"| node_infer
node_runner -->|"runs specialists"| node_external
node_runner -->|"writes blend"| node_blend
node_infer -->|"decodes exams"| node_dicom
node_infer -->|"selects series"| node_series
node_infer -->|"uses crop inputs"| node_tiles
node_infer -->|"uses window inputs"| node_windows
node_infer -->|"runs models"| node_models
node_tiles -->|"uses centre"| node_centre
node_tiles -->|"reads pixels"| node_dicom
node_windows -->|"uses centre"| node_centre
node_windows -->|"reads pixels"| node_dicom
node_external -->|"runs reader"| node_reader
node_external -->|"runs PF model"| node_pf
node_pf -->|"builds native inputs"| node_native
node_blend -->|"writes predictions"| node_submission
node_runner -->|"writes receipt"| node_submission
node_labels -->|"uses image panels"| node_panels
node_labels -->|"produces targets"| node_labelsdata
node_competition -->|"supplies MRI images"| node_panels
node_competition -->|"supplies training data"| node_stores
node_stores -->|"provides inputs"| node_training
node_labelsdata -->|"provides targets"| node_training
node_training -->|"trains weights"| node_models
node_labelsdata -->|"provides targets"| node_pftraining
node_pftraining -->|"trains specialist"| node_pf

click node_runner "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/predict.py"
click node_dicom "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/dicom.py"
click node_series "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/series.py"
click node_centre "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/centre.py"
click node_tiles "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/tiles.py"
click node_windows "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/windows.py"
click node_models "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/models.py"
click node_infer "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/infer.py"
click node_external "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/external.py"
click node_reader "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/reader/infer_c.py"
click node_pf "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/v731/kaggle_infer.py"
click node_native "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/v731/prepare_native.py"
click node_blend "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/blend.py"
click node_labels "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/labels.py"
click node_panels "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/panels.py"
click node_stores "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/stores.py"
click node_training "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/train.py"
click node_pftraining "https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/train/pf-specialist/train.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_competition toneBlue
class node_runner,node_dicom,node_series,node_centre,node_tiles,node_windows,node_models,node_infer toneAmber
class node_external,node_reader,node_pf,node_native toneMint
class node_labels,node_panels,node_stores,node_training,node_pftraining,node_labelsdata toneRose
class node_blend,node_submission toneIndigo
```

## Components

### MRI inputs

- **Competition data**

### Core inference

- [Prediction runner](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/predict.py): `predict.py`
- [DICOM decoding](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/dicom.py): `knee/dicom.py`
- [Series selection](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/series.py): `knee/series.py`
- [Knee centering](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/centre.py): `knee/centre.py`
- [Crop inputs](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/tiles.py): `knee/tiles.py`
- [Window inputs](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/windows.py): `knee/windows.py`
- [Core models](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/models.py): `knee/models.py`
- [Core inference](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/infer.py): `knee/infer.py`

### Specialist models

- [Reader members](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/external.py): `knee/external.py`
- [Reader inference](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/reader/infer_c.py): `external/reader/infer_c.py`
- [PF specialist](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/v731/kaggle_infer.py): `external/v731/kaggle_infer.py`
- [PF native inputs](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/v731/prepare_native.py): `external/v731/prepare_native.py`

### Labels and training

- [Label generation](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/labels.py): `knee/labels.py`
- [Expert image panels](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/panels.py): `knee/panels.py`
- [Training stores](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/stores.py): `knee/stores.py`
- [Core training](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/train.py): `knee/train.py`
- [PF training](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/external/train/pf-specialist/train.py): `external/train/pf-specialist/train.py`
- **Label tables**

### Prediction outputs

- [Rank blend](https://github.com/azamat1ch/rsna-knee-2nd-place/blob/main/knee/blend.py): `knee/blend.py`
- **Submission output**

## Connections

- Competition data → Prediction runner: provides exams
- Prediction runner → Core inference: runs core
- Prediction runner → Reader members: runs specialists (evidence: `predict.py`)
- Prediction runner → Rank blend: writes blend (evidence: `predict.py`)
- Core inference → DICOM decoding: decodes exams (evidence: `knee/infer.py`)
- Core inference → Series selection: selects series (evidence: `knee/infer.py`)
- Core inference → Crop inputs: uses crop inputs (evidence: `knee/infer.py`)
- Core inference → Window inputs: uses window inputs (evidence: `knee/infer.py`)
- Core inference → Core models: runs models (evidence: `knee/infer.py`)
- Crop inputs → Knee centering: uses centre (evidence: `knee/tiles.py`)
- Crop inputs → DICOM decoding: reads pixels (evidence: `knee/tiles.py`)
- Window inputs → Knee centering: uses centre (evidence: `knee/windows.py`)
- Window inputs → DICOM decoding: reads pixels (evidence: `knee/windows.py`)
- Reader members → Reader inference: runs reader (evidence: `knee/external.py`)
- Reader members → PF specialist: runs PF model (evidence: `knee/external.py`)
- PF specialist → PF native inputs: builds native inputs (evidence: `external/v731/kaggle_infer.py`)
- Rank blend → Submission output: writes predictions
- Prediction runner → Submission output: writes receipt
- Label generation → Expert image panels: uses image panels (evidence: `knee/labels.py`)
- Label generation → Label tables: produces targets
- Competition data → Expert image panels: supplies MRI images (evidence: `knee/panels.py`)
- Competition data → Training stores: supplies training data
- Training stores → Core training: provides inputs
- Label tables → Core training: provides targets
- Core training → Core models: trains weights (evidence: `knee/train.py`)
- Label tables → PF training: provides targets
- PF training → PF specialist: trains specialist
