# vt-vl-lab/ican architecture

> Architecture diagram of the GitHub repository vt-vl-lab/ican, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vt-vl-lab/ican
- Repository: https://github.com/vt-vl-lab/ican

## Overview

#### Purpose and Runtime

iCAN is a TensorFlow 1.x implementation of instance-centric attention for human-object interaction (HOI) detection. It trains and runs ResNet-50 models for V-COCO and HICO-DET, combining detected humans/objects into interaction predictions. The intended stack is Python 2.7, TensorFlow 1.1/1.2, CUDA 8, and Ubuntu 16.04.

#### Operational Entry Points

CLI scripts are the primary interface:
- Training: `tools/Train_ResNet_VCOCO.py`, `tools/Train_ResNet_HICO.py`
- Dataset inference: `tools/Test_ResNet_VCOCO.py`, `tools/Test_ResNet_HICO.py`
- Image-folder demo: `tools/Demo.py`
- V-COCO evaluation/diagnosis: `tools/Diagnose_VCOCO.py`

`tools/_init_paths.py` establishes imports from `lib/`, separating thin command wrappers from model, network, and utility implementations.

#### Dataset-Specific Training and Test Orchestration

Dataset adapters in `lib/models/` own graph execution, batching, checkpoint lifecycle, and result serialization for each benchmark:
- V-COCO training/testing: `lib/models/train_Solver_VCOCO.py`, `lib/models/test_VCOCO.py`
- HICO-DET training/testing: `lib/models/train_Solver_HICO.py`, `lib/models/test_HICO.py`
- Demo inference path: `lib/models/test_demo.py`

This is the main control boundary: tools select a dataset/model and iteration count; model modules drive TensorFlow sessions against prepared annotations and detector proposals.

#### iCAN Network Graphs

The core architectures are ResNet-50 HOI networks:
- `lib/networks/iCAN_ResNet50_VCOCO.py`
- `lib/networks/iCAN_ResNet50_VCOCO_Early.py`
- `lib/networks/iCAN_ResNet50_HICO.py`

They implement the benchmark-specific action spaces and iCAN attention/fusion variants. V-COCO has standard and early-fusion graphs; HICO-DET has a separate graph, rather than a single generic model with only configuration changes.

#### Detection-to-HOI Flow

Inference consumes external object detections, forms person-object candidate pairs, scores interaction classes, and writes detection results. Demo input is an image directory plus serialized detector output, producing serialized HOI output through `tools/Demo.py` and `lib/models/test_demo.py`.

Production-quality detections are expected from Detectron; the demo integrates tf-faster-rcnn. The detector integration/setup artifacts are `misc/Object_Detector.py` and `misc/setup_demo.sh`.

#### Data Preparation and Shared HOI Utilities

`lib/ult/ult.py` is the shared data/ROI and training-support layer used by model solvers. `lib/ult/config.py` centralizes repository paths and runtime configuration. Dataset/download setup is managed through `lib/ult/Download_data.py` and `misc/download_training_data.sh`.

Prior-based score adjustment is isolated in `lib/ult/apply_prior.py`, creating a clear post-network semantic constraint boundary between raw interaction scores and final HOI detections.

#### Evaluation, Conversion, and Analysis

V-COCO evaluation and error diagnosis use the bundled VSRL tooling:
- `lib/ult/vsrl_eval.py`
- `lib/ult/vcoco_diagnose.py`
- `tools/Diagnose_VCOCO.py`

HICO-DET final evaluation crosses into MATLAB-based conversion/evaluation support: `misc/Generate_detection.m` and `lib/ult/Generate_HICO_detection.py`. Thus Python/TensorFlow generates predictions, while HICO benchmark evaluation depends on external HICO-DET MATLAB code and generated detection files.

Main entry points: [`lib/models/train_Solver_VCOCO.py`](https://github.com/vt-vl-lab/ican/blob/master/lib/models/train_Solver_VCOCO.py) (V-COCO solver and test), [`lib/models/train_Solver_HICO.py`](https://github.com/vt-vl-lab/ican/blob/master/lib/models/train_Solver_HICO.py) (HICO solver and test), [`lib/ult/apply_prior.py`](https://github.com/vt-vl-lab/ican/blob/master/lib/ult/apply_prior.py) (Prior score adjustment), [`lib/models/test_demo.py`](https://github.com/vt-vl-lab/ican/blob/master/lib/models/test_demo.py) (Demo inference runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command entry points"]
  node_train_cli["Training CLIs<br/>Python commands"]
  node_test_cli["Dataset test CLIs<br/>Python commands"]
  node_demo_cli["Image-folder demo<br/>Python command<br/>[Demo.py]"]
  node_diagnose_cli["V-COCO diagnosis CLI<br/>Python command<br/>[Diagnose_VCOCO.py]"]
  node_import_paths["Import path bootstrap<br/>Python bootstrap<br/>[_init_paths.py]"]
end

subgraph group_orchestration["Dataset orchestration"]
  node_vcoco_solver["V-COCO solver and test<br/>TensorFlow orchestration"]
  node_hico_solver["HICO solver and test<br/>TensorFlow orchestration"]
  node_demo_runner["Demo inference runner<br/>TensorFlow orchestration<br/>[test_demo.py]"]
end

subgraph group_networks["iCAN network graphs"]
  node_vcoco_networks{{"V-COCO iCAN graphs<br/>ResNet-50 HOI networks"}}
  node_hico_network{{"HICO iCAN graph<br/>ResNet-50 HOI network"}}
end

subgraph group_data["Data and scoring"]
  node_hoi_data["ROI and training utilities<br/>HOI data layer<br/>[ult.py]"]
  node_runtime_config["Runtime configuration<br/>Python configuration<br/>[config.py]"]
  node_prior["Prior score adjustment<br/>HOI post-processing<br/>[apply_prior.py]"]
  node_data_download["Training-data setup<br/>Dataset preparation<br/>[Download_data.py]"]
end

subgraph group_evaluation["Evaluation and detector integration"]
  node_detector["Detector integration<br/>Object detector bridge<br/>[Object_Detector.py]"]
  node_vcoco_eval["V-COCO evaluation<br/>VSRL evaluation<br/>[vsrl_eval.py]"]
  node_hico_conversion["HICO detection conversion<br/>Python conversion"]
  node_matlab_eval["HICO MATLAB evaluation"]
end

node_train_cli -->|"bootstraps imports"| node_import_paths
node_test_cli -->|"bootstraps imports"| node_import_paths
node_demo_cli -->|"bootstraps imports"| node_import_paths
node_train_cli -->|"V-COCO train"| node_vcoco_solver
node_train_cli -->|"HICO train"| node_hico_solver
node_test_cli -->|"V-COCO test"| node_vcoco_solver
node_test_cli -->|"HICO test"| node_hico_solver
node_demo_cli -->|"runs inference"| node_demo_runner
node_vcoco_solver -->|"builds and executes"| node_vcoco_networks
node_hico_solver -->|"builds and executes"| node_hico_network
node_demo_runner -->|"scores HOI pairs"| node_vcoco_networks
node_vcoco_solver -->|"batches ROIs and annotations"| node_hoi_data
node_hico_solver -->|"batches ROIs and annotations"| node_hoi_data
node_hoi_data -->|"reads paths and settings"| node_runtime_config
node_detector -->|"person-object proposals"| node_demo_runner
node_demo_runner -->|"raw interaction scores"| node_prior
node_vcoco_solver -->|"benchmark predictions"| node_prior
node_hico_solver -->|"benchmark predictions"| node_prior
node_diagnose_cli -->|"evaluates and diagnoses"| node_vcoco_eval
node_prior -->|"final V-COCO detections"| node_vcoco_eval
node_prior -->|"final HICO detections"| node_hico_conversion
node_hico_conversion -->|"generated detection files"| node_matlab_eval
node_data_download -->|"prepared training data"| node_hoi_data

click node_train_cli "https://github.com/vt-vl-lab/ican/blob/master/tools/Train_ResNet_VCOCO.py"
click node_test_cli "https://github.com/vt-vl-lab/ican/blob/master/tools/Test_ResNet_VCOCO.py"
click node_demo_cli "https://github.com/vt-vl-lab/ican/blob/master/tools/Demo.py"
click node_diagnose_cli "https://github.com/vt-vl-lab/ican/blob/master/tools/Diagnose_VCOCO.py"
click node_import_paths "https://github.com/vt-vl-lab/ican/blob/master/tools/_init_paths.py"
click node_vcoco_solver "https://github.com/vt-vl-lab/ican/blob/master/lib/models/train_Solver_VCOCO.py"
click node_hico_solver "https://github.com/vt-vl-lab/ican/blob/master/lib/models/train_Solver_HICO.py"
click node_demo_runner "https://github.com/vt-vl-lab/ican/blob/master/lib/models/test_demo.py"
click node_vcoco_networks "https://github.com/vt-vl-lab/ican/blob/master/lib/networks/iCAN_ResNet50_VCOCO.py"
click node_hico_network "https://github.com/vt-vl-lab/ican/blob/master/lib/networks/iCAN_ResNet50_HICO.py"
click node_hoi_data "https://github.com/vt-vl-lab/ican/blob/master/lib/ult/ult.py"
click node_runtime_config "https://github.com/vt-vl-lab/ican/blob/master/lib/ult/config.py"
click node_prior "https://github.com/vt-vl-lab/ican/blob/master/lib/ult/apply_prior.py"
click node_detector "https://github.com/vt-vl-lab/ican/blob/master/misc/Object_Detector.py"
click node_vcoco_eval "https://github.com/vt-vl-lab/ican/blob/master/lib/ult/vsrl_eval.py"
click node_hico_conversion "https://github.com/vt-vl-lab/ican/blob/master/lib/ult/Generate_HICO_detection.py"
click node_matlab_eval "https://github.com/vt-vl-lab/ican/blob/master/misc/Generate_detection.m"
click node_data_download "https://github.com/vt-vl-lab/ican/blob/master/lib/ult/Download_data.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_train_cli,node_test_cli,node_demo_cli,node_diagnose_cli,node_import_paths toneBlue
class node_vcoco_solver,node_hico_solver,node_demo_runner toneAmber
class node_vcoco_networks,node_hico_network toneMint
class node_hoi_data,node_runtime_config,node_prior,node_data_download toneRose
class node_detector,node_vcoco_eval,node_hico_conversion,node_matlab_eval toneIndigo
```

## Components

### Command entry points

- [Training CLIs](https://github.com/vt-vl-lab/ican/blob/master/tools/Train_ResNet_VCOCO.py): Python commands · Select V-COCO or HICO training. · `tools/Train_ResNet_VCOCO.py`
- [Dataset test CLIs](https://github.com/vt-vl-lab/ican/blob/master/tools/Test_ResNet_VCOCO.py): Python commands · Run benchmark inference. · `tools/Test_ResNet_VCOCO.py`
- [Image-folder demo](https://github.com/vt-vl-lab/ican/blob/master/tools/Demo.py): Python command · `tools/Demo.py`
- [V-COCO diagnosis CLI](https://github.com/vt-vl-lab/ican/blob/master/tools/Diagnose_VCOCO.py): Python command · `tools/Diagnose_VCOCO.py`
- [Import path bootstrap](https://github.com/vt-vl-lab/ican/blob/master/tools/_init_paths.py): Python bootstrap · Adds lib/ implementations to command imports. · `tools/_init_paths.py`

### Dataset orchestration

- [V-COCO solver and test](https://github.com/vt-vl-lab/ican/blob/master/lib/models/train_Solver_VCOCO.py): TensorFlow orchestration · Drives sessions, batches, checkpoints, and result serialization. · `lib/models/train_Solver_VCOCO.py`
- [HICO solver and test](https://github.com/vt-vl-lab/ican/blob/master/lib/models/train_Solver_HICO.py): TensorFlow orchestration · Drives HICO training, inference, and serialized results. · `lib/models/train_Solver_HICO.py`
- [Demo inference runner](https://github.com/vt-vl-lab/ican/blob/master/lib/models/test_demo.py): TensorFlow orchestration · `lib/models/test_demo.py`

### iCAN network graphs

- [V-COCO iCAN graphs](https://github.com/vt-vl-lab/ican/blob/master/lib/networks/iCAN_ResNet50_VCOCO.py): ResNet-50 HOI networks · Standard and early-fusion V-COCO action graphs. · `lib/networks/iCAN_ResNet50_VCOCO.py`
- [HICO iCAN graph](https://github.com/vt-vl-lab/ican/blob/master/lib/networks/iCAN_ResNet50_HICO.py): ResNet-50 HOI network · Separate HICO-DET interaction graph. · `lib/networks/iCAN_ResNet50_HICO.py`

### Data and scoring

- [ROI and training utilities](https://github.com/vt-vl-lab/ican/blob/master/lib/ult/ult.py): HOI data layer · Prepares annotations, ROI inputs, and training support. · `lib/ult/ult.py`
- [Runtime configuration](https://github.com/vt-vl-lab/ican/blob/master/lib/ult/config.py): Python configuration · `lib/ult/config.py`
- [Prior score adjustment](https://github.com/vt-vl-lab/ican/blob/master/lib/ult/apply_prior.py): HOI post-processing · Applies semantic priors to raw interaction scores. · `lib/ult/apply_prior.py`
- [Training-data setup](https://github.com/vt-vl-lab/ican/blob/master/lib/ult/Download_data.py): Dataset preparation · `lib/ult/Download_data.py`

### Evaluation and detector integration

- [Detector integration](https://github.com/vt-vl-lab/ican/blob/master/misc/Object_Detector.py): Object detector bridge · Consumes Detectron detections; demo supports tf-faster-rcnn. · `misc/Object_Detector.py`
- [V-COCO evaluation](https://github.com/vt-vl-lab/ican/blob/master/lib/ult/vsrl_eval.py): VSRL evaluation · Scores predictions and supports error diagnosis. · `lib/ult/vsrl_eval.py`
- [HICO detection conversion](https://github.com/vt-vl-lab/ican/blob/master/lib/ult/Generate_HICO_detection.py): Python conversion · Generates HICO evaluation detections. · `lib/ult/Generate_HICO_detection.py`
- [HICO MATLAB evaluation](https://github.com/vt-vl-lab/ican/blob/master/misc/Generate_detection.m): MATLAB evaluation · Uses generated detection files with external HICO-DET code. · `misc/Generate_detection.m`

## Connections

- Training CLIs → Import path bootstrap: bootstraps imports
- Dataset test CLIs → Import path bootstrap: bootstraps imports
- Image-folder demo → Import path bootstrap: bootstraps imports
- Training CLIs → V-COCO solver and test: V-COCO train
- Training CLIs → HICO solver and test: HICO train
- Dataset test CLIs → V-COCO solver and test: V-COCO test
- Dataset test CLIs → HICO solver and test: HICO test
- Image-folder demo → Demo inference runner: runs inference
- V-COCO solver and test → V-COCO iCAN graphs: builds and executes
- HICO solver and test → HICO iCAN graph: builds and executes
- Demo inference runner → V-COCO iCAN graphs: scores HOI pairs
- V-COCO solver and test → ROI and training utilities: batches ROIs and annotations
- HICO solver and test → ROI and training utilities: batches ROIs and annotations
- ROI and training utilities → Runtime configuration: reads paths and settings
- Detector integration → Demo inference runner: person-object proposals
- Demo inference runner → Prior score adjustment: raw interaction scores
- V-COCO solver and test → Prior score adjustment: benchmark predictions
- HICO solver and test → Prior score adjustment: benchmark predictions
- V-COCO diagnosis CLI → V-COCO evaluation: evaluates and diagnoses
- Prior score adjustment → V-COCO evaluation: final V-COCO detections
- Prior score adjustment → HICO detection conversion: final HICO detections
- HICO detection conversion → HICO MATLAB evaluation: generated detection files
- Training-data setup → ROI and training utilities: prepared training data
