# tangqh03/pf-rpn architecture

> Architecture diagram of the GitHub repository tangqh03/pf-rpn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tangqh03/pf-rpn
- Repository: https://github.com/tangqh03/pf-rpn

## Overview

PF-RPN is an MMDetection-based, prompt-free open-set region proposal system: it treats categories as one `object` class and targets CD-FSOD and ODinW13 evaluation. The principal workflow prepares one-class data, loads and transforms images, runs PF-RPN proposal generation, then evaluates proposal recall. The README also documents source-domain training and the adapter, self-prompt, and query-selection designs. Dataset, API, head, and visualization excerpts provide partial implementation evidence; links among the model’s documented internal stages reflect the README, not inspected detector internals.

Main entry points: [`mmdet/datasets/base_det_dataset.py`](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/datasets/base_det_dataset.py) (Detection datasets), [`mmdet/apis/inference.py`](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/apis/inference.py) (Inference API), [`mmdet/models/detectors/pf_rpn.py`](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/detectors/pf_rpn.py) (PF-RPN detector), [`tools/train.py`](https://github.com/tangqh03/pf-rpn/blob/main/tools/train.py) (Training entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_annotation_tool["One-class sampling"]
  node_dataset["Detection datasets"]
  node_transforms["Image transforms<br/>[transforms.py]"]
end

subgraph group_runtime["Detection runtime"]
  node_model["PF-RPN detector<br/>[pf_rpn.py]"]
  node_adapter["Image-aware adapter<br/>[pf_rpn.py]"]
  node_self_prompt["Cascade self-prompt<br/>[pf_rpn.py]"]
  node_query_select["Centerness query selection"]
  node_proposals["Object proposals<br/>[det_data_sample.py]"]
end

subgraph group_learning["Training and evaluation"]
  node_train_config["PF-RPN config"]
  node_train_entry["Training entry<br/>[train.py]"]
  node_runner["Training loops<br/>[loops.py]"]
  node_eval["Proposal evaluation<br/>[coco_metric.py]"]
end

subgraph group_serving["Inference output"]
  node_infer_api["Inference API<br/>[inference.py]"]
  node_handler["TorchServe handler<br/>[mmdet_handler.py]"]
  node_visualizer["Prediction visualization"]
  node_predictions["Proposal results"]
end

node_user(("Engineer"))
node_source_data[("COCO + FSOD")]

node_source_data -->|"samples and merges"| node_annotation_tool
node_user -->|"runs preprocessing"| node_annotation_tool
node_annotation_tool -->|"writes annotations"| node_dataset
node_source_data -->|"provides images"| node_dataset
node_train_config -->|"configures training"| node_train_entry
node_train_entry -->|"builds data"| node_dataset
node_dataset -->|"applies pipeline"| node_transforms
node_train_entry -->|"starts training"| node_runner
node_runner -->|"trains model"| node_model
node_dataset -->|"supplies batches"| node_model
node_model -->|"extracts visual features"| node_adapter
node_adapter -->|"constructs pseudo text"| node_self_prompt
node_self_prompt -->|"enhances visual-text features"| node_query_select
node_query_select -->|"selects proposals"| node_proposals
node_proposals -->|"evaluates recall"| node_eval
node_user -->|"requests inference"| node_infer_api
node_infer_api -->|"runs detector"| node_model
node_infer_api -->|"renders predictions"| node_visualizer
node_visualizer -->|"produces visualization"| node_predictions
node_user -->|"submits image"| node_handler
node_handler -->|"calls inference"| node_infer_api
node_handler -->|"formats detections"| node_predictions

click node_annotation_tool "https://github.com/tangqh03/pf-rpn/blob/main/tools/merge_classes_and_sample_subset.py"
click node_dataset "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/datasets/base_det_dataset.py"
click node_transforms "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/datasets/transforms/transforms.py"
click node_train_config "https://github.com/tangqh03/pf-rpn/blob/main/configs/pf-rpn/pf-rpn_coco-imagenet.py"
click node_train_entry "https://github.com/tangqh03/pf-rpn/blob/main/tools/train.py"
click node_runner "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/engine/runner/loops.py"
click node_model "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/detectors/pf_rpn.py"
click node_adapter "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/detectors/pf_rpn.py"
click node_self_prompt "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/detectors/pf_rpn.py"
click node_query_select "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/dense_heads/grounding_dino_head.py"
click node_proposals "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/structures/det_data_sample.py"
click node_eval "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/evaluation/metrics/coco_metric.py"
click node_infer_api "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/apis/inference.py"
click node_handler "https://github.com/tangqh03/pf-rpn/blob/main/tools/deployment/mmdet_handler.py"
click node_visualizer "https://github.com/tangqh03/pf-rpn/blob/main/mmdet/visualization/local_visualizer.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_annotation_tool,node_dataset,node_transforms toneBlue
class node_model,node_adapter,node_self_prompt,node_query_select,node_proposals,node_source_data toneAmber
class node_train_config,node_train_entry,node_runner,node_eval toneMint
class node_infer_api,node_handler,node_visualizer,node_predictions toneRose
class node_user toneIndigo
```

## Components

### Data preparation

- [One-class sampling](https://github.com/tangqh03/pf-rpn/blob/main/tools/merge_classes_and_sample_subset.py): `tools/merge_classes_and_sample_subset.py`
- [Detection datasets](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/datasets/base_det_dataset.py): `mmdet/datasets/base_det_dataset.py`
- [Image transforms](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/datasets/transforms/transforms.py): `mmdet/datasets/transforms/transforms.py`

### Detection runtime

- [PF-RPN detector](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/detectors/pf_rpn.py): `mmdet/models/detectors/pf_rpn.py`
- [Image-aware adapter](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/detectors/pf_rpn.py): `mmdet/models/detectors/pf_rpn.py`
- [Cascade self-prompt](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/detectors/pf_rpn.py): `mmdet/models/detectors/pf_rpn.py`
- [Centerness query selection](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/models/dense_heads/grounding_dino_head.py): `mmdet/models/dense_heads/grounding_dino_head.py`
- [Object proposals](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/structures/det_data_sample.py): `mmdet/structures/det_data_sample.py`

### Training and evaluation

- [PF-RPN config](https://github.com/tangqh03/pf-rpn/blob/main/configs/pf-rpn/pf-rpn_coco-imagenet.py): `configs/pf-rpn/pf-rpn_coco-imagenet.py`
- [Training entry](https://github.com/tangqh03/pf-rpn/blob/main/tools/train.py): `tools/train.py`
- [Training loops](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/engine/runner/loops.py): `mmdet/engine/runner/loops.py`
- [Proposal evaluation](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/evaluation/metrics/coco_metric.py): `mmdet/evaluation/metrics/coco_metric.py`

### Inference output

- [Inference API](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/apis/inference.py): `mmdet/apis/inference.py`
- [TorchServe handler](https://github.com/tangqh03/pf-rpn/blob/main/tools/deployment/mmdet_handler.py): `tools/deployment/mmdet_handler.py`
- [Prediction visualization](https://github.com/tangqh03/pf-rpn/blob/main/mmdet/visualization/local_visualizer.py): `mmdet/visualization/local_visualizer.py`
- **Proposal results**

### Other components

- **Engineer**
- **COCO + FSOD**

## Connections

- COCO + FSOD → One-class sampling: samples and merges
- Engineer → One-class sampling: runs preprocessing
- One-class sampling → Detection datasets: writes annotations
- COCO + FSOD → Detection datasets: provides images
- PF-RPN config → Training entry: configures training
- Training entry → Detection datasets: builds data
- Detection datasets → Image transforms: applies pipeline
- Training entry → Training loops: starts training
- Training loops → PF-RPN detector: trains model
- Detection datasets → PF-RPN detector: supplies batches
- PF-RPN detector → Image-aware adapter: extracts visual features
- Image-aware adapter → Cascade self-prompt: constructs pseudo text
- Cascade self-prompt → Centerness query selection: enhances visual-text features
- Centerness query selection → Object proposals: selects proposals
- Object proposals → Proposal evaluation: evaluates recall
- Engineer → Inference API: requests inference
- Inference API → PF-RPN detector: runs detector
- Inference API → Prediction visualization: renders predictions
- Prediction visualization → Proposal results: produces visualization
- Engineer → TorchServe handler: submits image
- TorchServe handler → Inference API: calls inference
- TorchServe handler → Proposal results: formats detections
