# tencent/tencent-ml-images architecture

> Architecture diagram of the GitHub repository tencent/tencent-ml-images, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tencent/tencent-ml-images
- Repository: https://github.com/tencent/tencent-ml-images

## Overview

Tencent ML-Images combines a large multi-label image dataset with a ResNet-101 training and transfer-learning project. The main workflow is to obtain labeled images, convert them to TFRecords, load and preprocess batches, train or fine-tune ResNet, then use saved checkpoints for classification or feature extraction. The README also documents ImageNet and Open Images data, semantic categories, and downstream evaluation. Some capabilities are documented but their implementing files were not sampled; those are represented at the supported directory level, and uncertain links are omitted.

Main entry points: [`train.py`](https://github.com/tencent/tencent-ml-images/blob/master/train.py) (ML-Images training), [`finetune.py`](https://github.com/tencent/tencent-ml-images/blob/master/finetune.py) (ImageNet fine-tuning), [`models/resnet.py`](https://github.com/tencent/tencent-ml-images/blob/master/models/resnet.py) (ResNet architecture), [`data`](https://github.com/tencent/tencent-ml-images/tree/master/data) (Model checkpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dataset and preparation"]
  node_urlsets["Labeled image URLs"]
  node_downloader["Image downloader"]
  node_categorydata["Categories and labels"]
  node_imagefiles["Downloaded images"]
  node_converter["TFRecord converter<br/>[tfrecord.py]"]
  node_records[("TFRecord dataset")]
  node_dataset["Dataset file access<br/>[dataset.py]"]
  node_preprocess["Image preprocessing"]
end

subgraph group_learning["Model and training"]
  node_flags["Runtime configuration<br/>[flags.py]"]
  node_resnet["ResNet architecture<br/>[resnet.py]"]
  node_pretrain["ML-Images training<br/>[train.py]"]
  node_finetune["ImageNet fine-tuning<br/>[finetune.py]"]
  node_checkpoints[("Model checkpoints")]
end

subgraph group_use["Inference and outputs"]
  node_classification["Image classification"]
  node_features["Feature extraction<br/>[extract_feature.py]"]
  node_predictions["Class predictions"]
  node_featureoutput["Feature vectors<br/>[extract_feature.py]"]
end

node_imagenet(("ImageNet"))
node_openimages(("Open Images"))

node_imagenet -->|"contributes images"| node_urlsets
node_openimages -->|"contributes images"| node_urlsets
node_urlsets -->|"provides URLs"| node_downloader
node_downloader -->|"downloads images"| node_imagefiles
node_categorydata -->|"describes labels"| node_urlsets
node_imagefiles -->|"converts image data"| node_converter
node_converter -->|"writes records"| node_records
node_pretrain -->|"lists data files"| node_dataset
node_finetune -->|"lists data files"| node_dataset
node_pretrain -->|"reads batches"| node_records
node_pretrain -->|"preprocesses images"| node_preprocess
node_finetune -->|"preprocesses images"| node_preprocess
node_pretrain -->|"builds model"| node_resnet
node_finetune -->|"builds model"| node_resnet
node_flags -->|"configures model"| node_resnet
node_pretrain -->|"reads options"| node_flags
node_finetune -->|"reads options"| node_flags
node_pretrain -->|"saves checkpoints"| node_checkpoints
node_finetune -->|"restores weights"| node_checkpoints
node_classification -->|"runs inference"| node_resnet
node_features -->|"extracts features"| node_resnet
node_checkpoints -->|"restores model"| node_classification
node_checkpoints -->|"restores model"| node_features
node_classification -->|"writes predictions"| node_predictions
node_features -->|"writes vectors"| node_featureoutput

click node_urlsets "https://github.com/tencent/tencent-ml-images/tree/master/data"
click node_downloader "https://github.com/tencent/tencent-ml-images/blob/master/data/download_urls_multithreading.py"
click node_categorydata "https://github.com/tencent/tencent-ml-images/blob/master/data/dictionary_and_semantic_hierarchy.txt"
click node_imagefiles "https://github.com/tencent/tencent-ml-images/tree/master/data/images"
click node_converter "https://github.com/tencent/tencent-ml-images/blob/master/data/tfrecord.py"
click node_records "https://github.com/tencent/tencent-ml-images/tree/master/data/tfrecords"
click node_dataset "https://github.com/tencent/tencent-ml-images/blob/master/data_processing/dataset.py"
click node_preprocess "https://github.com/tencent/tencent-ml-images/blob/master/data_processing/image_preprocessing.py"
click node_flags "https://github.com/tencent/tencent-ml-images/blob/master/flags.py"
click node_resnet "https://github.com/tencent/tencent-ml-images/blob/master/models/resnet.py"
click node_pretrain "https://github.com/tencent/tencent-ml-images/blob/master/train.py"
click node_finetune "https://github.com/tencent/tencent-ml-images/blob/master/finetune.py"
click node_checkpoints "https://github.com/tencent/tencent-ml-images/tree/master/data"
click node_classification "https://github.com/tencent/tencent-ml-images/blob/master/image_classification.py"
click node_features "https://github.com/tencent/tencent-ml-images/blob/master/extract_feature.py"
click node_predictions "https://github.com/tencent/tencent-ml-images/blob/master/image_classification.py"
click node_featureoutput "https://github.com/tencent/tencent-ml-images/blob/master/extract_feature.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_urlsets,node_downloader,node_categorydata,node_imagefiles,node_converter,node_records,node_dataset,node_preprocess toneBlue
class node_flags,node_resnet,node_pretrain,node_finetune,node_checkpoints toneAmber
class node_classification,node_features,node_predictions,node_featureoutput toneMint
class node_imagenet,node_openimages toneIndigo
```

## Components

### Dataset and preparation

- [Labeled image URLs](https://github.com/tencent/tencent-ml-images/tree/master/data): `data`
- [Image downloader](https://github.com/tencent/tencent-ml-images/blob/master/data/download_urls_multithreading.py): `data/download_urls_multithreading.py`
- [Categories and labels](https://github.com/tencent/tencent-ml-images/blob/master/data/dictionary_and_semantic_hierarchy.txt): `data/dictionary_and_semantic_hierarchy.txt`
- [Downloaded images](https://github.com/tencent/tencent-ml-images/tree/master/data/images): `data/images`
- [TFRecord converter](https://github.com/tencent/tencent-ml-images/blob/master/data/tfrecord.py): `data/tfrecord.py`
- [TFRecord dataset](https://github.com/tencent/tencent-ml-images/tree/master/data/tfrecords): `data/tfrecords`
- [Dataset file access](https://github.com/tencent/tencent-ml-images/blob/master/data_processing/dataset.py): `data_processing/dataset.py`
- [Image preprocessing](https://github.com/tencent/tencent-ml-images/blob/master/data_processing/image_preprocessing.py): `data_processing/image_preprocessing.py`

### Model and training

- [Runtime configuration](https://github.com/tencent/tencent-ml-images/blob/master/flags.py): `flags.py`
- [ResNet architecture](https://github.com/tencent/tencent-ml-images/blob/master/models/resnet.py): `models/resnet.py`
- [ML-Images training](https://github.com/tencent/tencent-ml-images/blob/master/train.py): `train.py`
- [ImageNet fine-tuning](https://github.com/tencent/tencent-ml-images/blob/master/finetune.py): `finetune.py`
- [Model checkpoints](https://github.com/tencent/tencent-ml-images/tree/master/data): `data`

### Inference and outputs

- [Image classification](https://github.com/tencent/tencent-ml-images/blob/master/image_classification.py): `image_classification.py`
- [Feature extraction](https://github.com/tencent/tencent-ml-images/blob/master/extract_feature.py): `extract_feature.py`
- [Class predictions](https://github.com/tencent/tencent-ml-images/blob/master/image_classification.py): `image_classification.py`
- [Feature vectors](https://github.com/tencent/tencent-ml-images/blob/master/extract_feature.py): `extract_feature.py`

### Other components

- **ImageNet**
- **Open Images**

## Connections

- ImageNet → Labeled image URLs: contributes images (evidence: `README.md`)
- Open Images → Labeled image URLs: contributes images (evidence: `README.md`)
- Labeled image URLs → Image downloader: provides URLs (evidence: `README.md`)
- Image downloader → Downloaded images: downloads images (evidence: `data/download_urls_multithreading.py`)
- Categories and labels → Labeled image URLs: describes labels (evidence: `README.md`)
- Downloaded images → TFRecord converter: converts image data (evidence: `data/tfrecord.py`)
- TFRecord converter → TFRecord dataset: writes records (evidence: `data/tfrecord.py`)
- ML-Images training → Dataset file access: lists data files (evidence: `train.py`)
- ImageNet fine-tuning → Dataset file access: lists data files (evidence: `finetune.py`)
- ML-Images training → TFRecord dataset: reads batches (evidence: `train.py`)
- ML-Images training → Image preprocessing: preprocesses images (evidence: `train.py`)
- ImageNet fine-tuning → Image preprocessing: preprocesses images (evidence: `finetune.py`)
- ML-Images training → ResNet architecture: builds model (evidence: `train.py`)
- ImageNet fine-tuning → ResNet architecture: builds model (evidence: `finetune.py`)
- Runtime configuration → ResNet architecture: configures model (evidence: `models/resnet.py`)
- ML-Images training → Runtime configuration: reads options (evidence: `train.py`)
- ImageNet fine-tuning → Runtime configuration: reads options (evidence: `finetune.py`)
- ML-Images training → Model checkpoints: saves checkpoints (evidence: `README.md`)
- ImageNet fine-tuning → Model checkpoints: restores weights (evidence: `finetune.py`)
- Image classification → ResNet architecture: runs inference (evidence: `image_classification.py`)
- Feature extraction → ResNet architecture: extracts features (evidence: `extract_feature.py`)
- Model checkpoints → Image classification: restores model (evidence: `image_classification.py`)
- Model checkpoints → Feature extraction: restores model (evidence: `extract_feature.py`)
- Image classification → Class predictions: writes predictions (evidence: `image_classification.py`)
- Feature extraction → Feature vectors: writes vectors (evidence: `extract_feature.py`)
