# alimama-creative/postermaker architecture

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

- Interactive diagram: https://gitdiagram.com/alimama-creative/postermaker
- Repository: https://github.com/alimama-creative/postermaker

## Overview

PosterMaker generates product posters by combining a supplied image, subject mask, prompt, and positioned text with an SD3 pipeline controlled for inpainting and text rendering. Its broader product scope includes staged model training, evaluation, and a reward-learning variant. The README documents these capabilities; sampled source confirms input preprocessing and key model components, while some training and inference wiring is supported only by the SOURCE INDEX.

Main entry points: [`train_sd3_stage2_with_reward.py`](https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage2_with_reward.py) (Reward training), [`utils/eval_utils.py`](https://github.com/alimama-creative/postermaker/blob/main/utils/eval_utils.py) (Model evaluation), [`train_sd3_stage1.py`](https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage1.py) (Stage 1 training), [`train_sd3_stage2.py`](https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage2.py) (Stage 2 training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Poster generation"]
  node_infer["Inference entry<br/>[inference.py]"]
  node_prep["Input preprocessing<br/>[data_processor.py]"]
  node_pipeline["SD3 pipeline<br/>[pipeline_sd3.py]"]
  node_output["Generated posters"]
end

subgraph group_models["Generation models"]
  node_embed["Text embeddings<br/>[text_embedder.py]"]
  node_controlnet["ControlNet models<br/>[controlnet_sd3.py]"]
  node_transformer["SD3 transformer<br/>[transformer_sd3.py]"]
  node_adapter["Text adapter<br/>[adapter_models.py]"]
end

subgraph group_training["Model training"]
  node_stage1["Stage 1 training"]
  node_stage2["Stage 2 training"]
  node_reward["Reward training"]
end

subgraph group_data["Data and evaluation"]
  node_trainset["Training dataset"]
  node_evalset["Evaluation dataset"]
  node_evaluation["Model evaluation<br/>[eval_utils.py]"]
  node_helpers["Image and text utilities<br/>[utils.py]"]
end

subgraph group_vision["Vision and recognition"]
  node_recognizer["OCR recognizer<br/>[recognizer.py]"]
  node_sam["SAM detection<br/>[inference.py]"]
end

node_user(("Poster inputs"))

node_user -->|"provides inputs"| node_infer
node_infer -->|"preprocesses"| node_prep
node_prep -->|"encodes text"| node_embed
node_prep -->|"uses image utilities"| node_helpers
node_infer -->|"runs generation"| node_pipeline
node_pipeline -->|"applies controls"| node_controlnet
node_pipeline -.->|"denoises with"| node_transformer
node_pipeline -->|"produces images"| node_output
node_stage1 -->|"loads data"| node_trainset
node_stage2 -->|"loads data"| node_trainset
node_reward -->|"loads data"| node_trainset
node_stage1 -->|"trains model"| node_controlnet
node_stage2 -->|"trains model"| node_controlnet
node_reward -->|"trains model"| node_controlnet
node_reward -->|"uses detection"| node_sam
node_stage1 -->|"evaluates with"| node_evaluation
node_stage2 -->|"evaluates with"| node_evaluation
node_reward -->|"evaluates with"| node_evaluation
node_evaluation -->|"loads samples"| node_evalset
node_evaluation -->|"scores text"| node_recognizer
node_stage1 -->|"configures"| node_adapter
node_stage2 -->|"configures"| node_adapter
node_reward -->|"configures"| node_adapter

click node_infer "https://github.com/alimama-creative/postermaker/blob/main/inference.py"
click node_prep "https://github.com/alimama-creative/postermaker/blob/main/utils/data_processor.py"
click node_embed "https://github.com/alimama-creative/postermaker/blob/main/models/text_embedder.py"
click node_pipeline "https://github.com/alimama-creative/postermaker/blob/main/pipelines/pipeline_sd3.py"
click node_controlnet "https://github.com/alimama-creative/postermaker/blob/main/models/controlnet_sd3.py"
click node_transformer "https://github.com/alimama-creative/postermaker/blob/main/models/transformer_sd3.py"
click node_adapter "https://github.com/alimama-creative/postermaker/blob/main/models/adapter_models.py"
click node_stage1 "https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage1.py"
click node_stage2 "https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage2.py"
click node_reward "https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage2_with_reward.py"
click node_trainset "https://github.com/alimama-creative/postermaker/blob/main/data_utils/poster_dataset_e2e_train.py"
click node_evalset "https://github.com/alimama-creative/postermaker/blob/main/data_utils/poster_dataset_e2e_eval.py"
click node_evaluation "https://github.com/alimama-creative/postermaker/blob/main/utils/eval_utils.py"
click node_recognizer "https://github.com/alimama-creative/postermaker/blob/main/models/recognizer.py"
click node_sam "https://github.com/alimama-creative/postermaker/blob/main/detection_utils/inference.py"
click node_helpers "https://github.com/alimama-creative/postermaker/blob/main/utils/utils.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_infer,node_prep,node_pipeline,node_output toneBlue
class node_embed,node_controlnet,node_transformer,node_adapter toneAmber
class node_stage1,node_stage2,node_reward toneMint
class node_trainset,node_evalset,node_evaluation,node_helpers toneRose
class node_recognizer,node_sam,node_user toneIndigo
```

## Components

### Poster generation

- [Inference entry](https://github.com/alimama-creative/postermaker/blob/main/inference.py): `inference.py`
- [Input preprocessing](https://github.com/alimama-creative/postermaker/blob/main/utils/data_processor.py): `utils/data_processor.py`
- [SD3 pipeline](https://github.com/alimama-creative/postermaker/blob/main/pipelines/pipeline_sd3.py): `pipelines/pipeline_sd3.py`
- **Generated posters**

### Generation models

- [Text embeddings](https://github.com/alimama-creative/postermaker/blob/main/models/text_embedder.py): `models/text_embedder.py`
- [ControlNet models](https://github.com/alimama-creative/postermaker/blob/main/models/controlnet_sd3.py): `models/controlnet_sd3.py`
- [SD3 transformer](https://github.com/alimama-creative/postermaker/blob/main/models/transformer_sd3.py): `models/transformer_sd3.py`
- [Text adapter](https://github.com/alimama-creative/postermaker/blob/main/models/adapter_models.py): `models/adapter_models.py`

### Model training

- [Stage 1 training](https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage1.py): `train_sd3_stage1.py`
- [Stage 2 training](https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage2.py): `train_sd3_stage2.py`
- [Reward training](https://github.com/alimama-creative/postermaker/blob/main/train_sd3_stage2_with_reward.py): `train_sd3_stage2_with_reward.py`

### Data and evaluation

- [Training dataset](https://github.com/alimama-creative/postermaker/blob/main/data_utils/poster_dataset_e2e_train.py): `data_utils/poster_dataset_e2e_train.py`
- [Evaluation dataset](https://github.com/alimama-creative/postermaker/blob/main/data_utils/poster_dataset_e2e_eval.py): `data_utils/poster_dataset_e2e_eval.py`
- [Model evaluation](https://github.com/alimama-creative/postermaker/blob/main/utils/eval_utils.py): `utils/eval_utils.py`
- [Image and text utilities](https://github.com/alimama-creative/postermaker/blob/main/utils/utils.py): `utils/utils.py`

### Vision and recognition

- [OCR recognizer](https://github.com/alimama-creative/postermaker/blob/main/models/recognizer.py): `models/recognizer.py`
- [SAM detection](https://github.com/alimama-creative/postermaker/blob/main/detection_utils/inference.py): `detection_utils/inference.py`

### Other components

- **Poster inputs**

## Connections

- Poster inputs → Inference entry: provides inputs (evidence: `README.md`)
- Inference entry → Input preprocessing: preprocesses (evidence: `inference.py`)
- Input preprocessing → Text embeddings: encodes text (evidence: `utils/data_processor.py`)
- Input preprocessing → Image and text utilities: uses image utilities (evidence: `utils/data_processor.py`)
- Inference entry → SD3 pipeline: runs generation (evidence: `inference.py`)
- SD3 pipeline → ControlNet models: applies controls (evidence: `pipelines/pipeline_sd3.py`)
- SD3 pipeline → SD3 transformer: denoises with
- SD3 pipeline → Generated posters: produces images (evidence: `README.md`)
- Stage 1 training → Training dataset: loads data (evidence: `train_sd3_stage1.py`)
- Stage 2 training → Training dataset: loads data (evidence: `train_sd3_stage2.py`)
- Reward training → Training dataset: loads data (evidence: `train_sd3_stage2_with_reward.py`)
- Stage 1 training → ControlNet models: trains model (evidence: `train_sd3_stage1.py`)
- Stage 2 training → ControlNet models: trains model (evidence: `train_sd3_stage2.py`)
- Reward training → ControlNet models: trains model (evidence: `train_sd3_stage2_with_reward.py`)
- Reward training → SAM detection: uses detection (evidence: `train_sd3_stage2_with_reward.py`)
- Stage 1 training → Model evaluation: evaluates with (evidence: `train_sd3_stage1.py`)
- Stage 2 training → Model evaluation: evaluates with (evidence: `train_sd3_stage2.py`)
- Reward training → Model evaluation: evaluates with (evidence: `train_sd3_stage2_with_reward.py`)
- Model evaluation → Evaluation dataset: loads samples (evidence: `utils/eval_utils.py`)
- Model evaluation → OCR recognizer: scores text (evidence: `utils/eval_utils.py`)
- Stage 1 training → Text adapter: configures (evidence: `train_sd3_stage1.py`)
- Stage 2 training → Text adapter: configures (evidence: `train_sd3_stage2.py`)
- Reward training → Text adapter: configures (evidence: `train_sd3_stage2_with_reward.py`)
