# zhuminglian/shine architecture

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

- Interactive diagram: https://gitdiagram.com/zhuminglian/shine
- Repository: https://github.com/zhuminglian/shine

## Overview

SHINE is a training-free image-composition framework: a user supplies a foreground reference and mask, a background with placement information, and a prompt; an adapter- or LoRA-based inference entry point generates a composition. The model code includes customized FLUX components for subject conditioning and attention. Separate evaluation scripts assess single images and the DreamEditBench and ComplexCompo benchmarks using image-similarity and quality metrics. The README documents these workflows and capabilities; several script and model connections are therefore represented at the documented subsystem level because their full source was not sampled.

Main entry points: [`models/adapter/pipeline.py`](https://github.com/zhuminglian/shine/blob/main/models/adapter/pipeline.py) (Adapter Pipeline), [`evaluation/evaluation.py`](https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation.py) (Single Image Evaluation), [`models/lora/SHINE_pipeline_flux.py`](https://github.com/zhuminglian/shine/blob/main/models/lora/SHINE_pipeline_flux.py) (LoRA Pipeline), [`evaluation/evaluation_complexcompo.py`](https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation_complexcompo.py) (ComplexCompo Evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Composition Inference"]
  node_inputs["Foreground And Scene"]
  node_adapter_entry["Adapter Entry<br/>[main_adapter.py]"]
  node_lora_entry["LoRA Entry<br/>[main_lora.py]"]
  node_composed_images["Composed Images"]
end

subgraph group_models["SHINE Model"]
  node_adapter_pipeline["Adapter Pipeline<br/>[pipeline.py]"]
  node_lora_pipeline["LoRA Pipeline"]
  node_transformer["FLUX Transformer"]
  node_adapter_attention["Adapter Attention<br/>[attn_processor.py]"]
  node_lora_attention["LoRA Attention"]
  node_resampler["Subject Resampler<br/>[resampler.py]"]
end

subgraph group_evaluation["Evaluation Workflows"]
  node_single_eval["Single Image Evaluation<br/>[evaluation.py]"]
  node_complex_eval["ComplexCompo Evaluation"]
  node_dream_eval["DreamEditBench Evaluation"]
  node_benchmark_data["Benchmark Data"]
  node_scores["Evaluation Scores"]
end

subgraph group_metrics["Evaluation Metrics"]
  node_clip["CLIP Similarity<br/>[clip_score.py]"]
  node_irf["IRF Similarity<br/>[IRF_score.py]"]
  node_dinov2["DINOv2 Similarity<br/>[dinov2_score.py]"]
end

node_user(("User"))

node_user -->|"provides inputs"| node_inputs
node_user -->|"runs inference"| node_adapter_entry
node_user -->|"runs inference"| node_lora_entry
node_inputs -->|"supplies scene"| node_adapter_entry
node_inputs -->|"supplies scene"| node_lora_entry
node_adapter_entry -->|"invokes"| node_adapter_pipeline
node_lora_entry -->|"invokes"| node_lora_pipeline
node_adapter_pipeline -->|"denoises with"| node_transformer
node_lora_pipeline -->|"denoises with"| node_transformer
node_adapter_pipeline -->|"uses attention"| node_adapter_attention
node_lora_pipeline -->|"uses attention"| node_lora_attention
node_adapter_pipeline -->|"projects subject features"| node_resampler
node_adapter_pipeline -->|"returns images"| node_composed_images
node_lora_pipeline -->|"returns images"| node_composed_images
node_user -->|"evaluates image"| node_single_eval
node_user -->|"evaluates benchmark"| node_complex_eval
node_user -->|"evaluates benchmark"| node_dream_eval
node_composed_images -->|"provides results"| node_single_eval
node_composed_images -->|"provides results"| node_complex_eval
node_composed_images -->|"provides results"| node_dream_eval
node_benchmark_data -->|"provides references"| node_complex_eval
node_benchmark_data -->|"provides references"| node_dream_eval
node_single_eval -->|"calculates similarity"| node_clip
node_single_eval -->|"calculates similarity"| node_irf
node_single_eval -->|"calculates similarity"| node_dinov2
node_complex_eval -->|"aggregates metrics"| node_scores
node_dream_eval -->|"aggregates metrics"| node_scores

click node_inputs "https://github.com/zhuminglian/shine/tree/main/examples"
click node_adapter_entry "https://github.com/zhuminglian/shine/blob/main/scripts/main_adapter.py"
click node_lora_entry "https://github.com/zhuminglian/shine/blob/main/scripts/main_lora.py"
click node_adapter_pipeline "https://github.com/zhuminglian/shine/blob/main/models/adapter/pipeline.py"
click node_lora_pipeline "https://github.com/zhuminglian/shine/blob/main/models/lora/SHINE_pipeline_flux.py"
click node_transformer "https://github.com/zhuminglian/shine/blob/main/models/SHINE_transformer_flux.py"
click node_adapter_attention "https://github.com/zhuminglian/shine/blob/main/models/adapter/attn_processor.py"
click node_lora_attention "https://github.com/zhuminglian/shine/blob/main/models/lora/SHINE_attn_processor.py"
click node_resampler "https://github.com/zhuminglian/shine/blob/main/models/adapter/resampler.py"
click node_single_eval "https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation.py"
click node_complex_eval "https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation_complexcompo.py"
click node_dream_eval "https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation_dreameditbench.py"
click node_benchmark_data "https://github.com/zhuminglian/shine/tree/main/examples"
click node_clip "https://github.com/zhuminglian/shine/blob/main/tools/clip_score.py"
click node_irf "https://github.com/zhuminglian/shine/blob/main/tools/IRF_score.py"
click node_dinov2 "https://github.com/zhuminglian/shine/blob/main/tools/dinov2_score.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_inputs,node_adapter_entry,node_lora_entry,node_composed_images,node_user toneBlue
class node_adapter_pipeline,node_lora_pipeline,node_transformer,node_adapter_attention,node_lora_attention,node_resampler toneAmber
class node_single_eval,node_complex_eval,node_dream_eval,node_benchmark_data,node_scores toneMint
class node_clip,node_irf,node_dinov2 toneRose
```

## Components

### Composition Inference

- [Foreground And Scene](https://github.com/zhuminglian/shine/tree/main/examples): `examples`
- [Adapter Entry](https://github.com/zhuminglian/shine/blob/main/scripts/main_adapter.py): `scripts/main_adapter.py`
- [LoRA Entry](https://github.com/zhuminglian/shine/blob/main/scripts/main_lora.py): `scripts/main_lora.py`
- **Composed Images**

### SHINE Model

- [Adapter Pipeline](https://github.com/zhuminglian/shine/blob/main/models/adapter/pipeline.py): `models/adapter/pipeline.py`
- [LoRA Pipeline](https://github.com/zhuminglian/shine/blob/main/models/lora/SHINE_pipeline_flux.py): `models/lora/SHINE_pipeline_flux.py`
- [FLUX Transformer](https://github.com/zhuminglian/shine/blob/main/models/SHINE_transformer_flux.py): `models/SHINE_transformer_flux.py`
- [Adapter Attention](https://github.com/zhuminglian/shine/blob/main/models/adapter/attn_processor.py): `models/adapter/attn_processor.py`
- [LoRA Attention](https://github.com/zhuminglian/shine/blob/main/models/lora/SHINE_attn_processor.py): `models/lora/SHINE_attn_processor.py`
- [Subject Resampler](https://github.com/zhuminglian/shine/blob/main/models/adapter/resampler.py): `models/adapter/resampler.py`

### Evaluation Workflows

- [Single Image Evaluation](https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation.py): `evaluation/evaluation.py`
- [ComplexCompo Evaluation](https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation_complexcompo.py): `evaluation/evaluation_complexcompo.py`
- [DreamEditBench Evaluation](https://github.com/zhuminglian/shine/blob/main/evaluation/evaluation_dreameditbench.py): `evaluation/evaluation_dreameditbench.py`
- [Benchmark Data](https://github.com/zhuminglian/shine/tree/main/examples): `examples`
- **Evaluation Scores**

### Evaluation Metrics

- [CLIP Similarity](https://github.com/zhuminglian/shine/blob/main/tools/clip_score.py): `tools/clip_score.py`
- [IRF Similarity](https://github.com/zhuminglian/shine/blob/main/tools/IRF_score.py): `tools/IRF_score.py`
- [DINOv2 Similarity](https://github.com/zhuminglian/shine/blob/main/tools/dinov2_score.py): `tools/dinov2_score.py`

### Other components

- **User**

## Connections

- User → Foreground And Scene: provides inputs
- User → Adapter Entry: runs inference
- User → LoRA Entry: runs inference
- Foreground And Scene → Adapter Entry: supplies scene
- Foreground And Scene → LoRA Entry: supplies scene
- Adapter Entry → Adapter Pipeline: invokes
- LoRA Entry → LoRA Pipeline: invokes
- Adapter Pipeline → FLUX Transformer: denoises with
- LoRA Pipeline → FLUX Transformer: denoises with
- Adapter Pipeline → Adapter Attention: uses attention
- LoRA Pipeline → LoRA Attention: uses attention
- Adapter Pipeline → Subject Resampler: projects subject features
- Adapter Pipeline → Composed Images: returns images
- LoRA Pipeline → Composed Images: returns images
- User → Single Image Evaluation: evaluates image
- User → ComplexCompo Evaluation: evaluates benchmark
- User → DreamEditBench Evaluation: evaluates benchmark
- Composed Images → Single Image Evaluation: provides results
- Composed Images → ComplexCompo Evaluation: provides results
- Composed Images → DreamEditBench Evaluation: provides results
- Benchmark Data → ComplexCompo Evaluation: provides references
- Benchmark Data → DreamEditBench Evaluation: provides references
- Single Image Evaluation → CLIP Similarity: calculates similarity
- Single Image Evaluation → IRF Similarity: calculates similarity
- Single Image Evaluation → DINOv2 Similarity: calculates similarity
- ComplexCompo Evaluation → Evaluation Scores: aggregates metrics
- DreamEditBench Evaluation → Evaluation Scores: aggregates metrics
