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---
|
| 11 |
|
| 12 |
+
# Layout Non-Alignment
|
| 13 |
+
|
| 14 |
+
## Description
|
| 15 |
+
|
| 16 |
+
The Layout Non-Alignment metric quantifies the extent of spatial non-alignment between layout elements. This metric evaluates layouts by detecting elements that break alignment patterns, providing insights into layout organization quality and visual coherence.
|
| 17 |
+
|
| 18 |
+
## What It Measures
|
| 19 |
+
|
| 20 |
+
This metric computes non-alignment scores that measure:
|
| 21 |
+
|
| 22 |
+
- **Alignment violations**: Elements that don't align with others along edges or centers
|
| 23 |
+
- **Spatial organization**: How consistently elements follow grid or alignment patterns
|
| 24 |
+
- **Visual disorder**: Degree of positional inconsistency between elements
|
| 25 |
+
|
| 26 |
+
The metric comes from PosterLayout (Hsu et al., CVPR 2023) and AC-GAN (Li et al., TVCG 2021) research, specifically designed for evaluating poster and graphic design layouts.
|
| 27 |
+
|
| 28 |
+
## Metric Details
|
| 29 |
+
|
| 30 |
+
- Analyzes element edge positions (left, right, top, bottom) to detect alignment patterns
|
| 31 |
+
- Computes delta (minimum distance) between element edges
|
| 32 |
+
- Applies logarithmic transformation to penalize near-misses more than obvious non-alignments
|
| 33 |
+
- Lower scores indicate better overall alignment (less non-alignment)
|
| 34 |
+
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
### Installation
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
pip install evaluate
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
### Basic Example
|
| 44 |
+
|
| 45 |
+
```python
|
| 46 |
+
import evaluate
|
| 47 |
+
import numpy as np
|
| 48 |
+
|
| 49 |
+
# Load the metric with canvas dimensions
|
| 50 |
+
metric = evaluate.load(
|
| 51 |
+
"creative-graphic-design/layout-non-alignment",
|
| 52 |
+
canvas_width=360,
|
| 53 |
+
canvas_height=504
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# Single layout processing
|
| 57 |
+
predictions = np.random.rand(1, 25, 4) # (batch, max_elements, coordinates)
|
| 58 |
+
gold_labels = np.random.randint(0, 4, size=(1, 25)) # (batch, max_elements)
|
| 59 |
+
score = metric.compute(predictions=predictions, gold_labels=gold_labels)
|
| 60 |
+
print(score)
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
### Batch Processing Example
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
import evaluate
|
| 67 |
+
import numpy as np
|
| 68 |
+
|
| 69 |
+
# Load the metric
|
| 70 |
+
metric = evaluate.load(
|
| 71 |
+
"creative-graphic-design/layout-non-alignment",
|
| 72 |
+
canvas_width=360,
|
| 73 |
+
canvas_height=504
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
# Batch processing
|
| 77 |
+
batch_size = 128
|
| 78 |
+
predictions = np.random.rand(batch_size, 25, 4)
|
| 79 |
+
gold_labels = np.random.randint(0, 4, size=(batch_size, 25))
|
| 80 |
+
score = metric.compute(predictions=predictions, gold_labels=gold_labels)
|
| 81 |
+
print(score)
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## Parameters
|
| 85 |
+
|
| 86 |
+
### Initialization Parameters
|
| 87 |
+
|
| 88 |
+
- **canvas_width** (`int`, required): Width of the canvas in pixels
|
| 89 |
+
- **canvas_height** (`int`, required): Height of the canvas in pixels
|
| 90 |
+
|
| 91 |
+
### Computation Parameters
|
| 92 |
+
|
| 93 |
+
- **predictions** (`list` of `lists` of `float`): Normalized bounding boxes in ltrb (left-top-right-bottom) format
|
| 94 |
+
- **gold_labels** (`list` of `lists` of `int`): Class labels for each element (0 = padding/invalid)
|
| 95 |
+
|
| 96 |
+
**Note**: Elements with `gold_labels == 0` are treated as padding and excluded from computation. Very small elements (< 0.1% of canvas area) are also filtered out.
|
| 97 |
+
|
| 98 |
+
## Returns
|
| 99 |
+
|
| 100 |
+
Returns a `float` value representing the non-alignment score.
|
| 101 |
+
|
| 102 |
+
## Interpretation
|
| 103 |
+
|
| 104 |
+
- **Lower is better**: Less non-alignment indicates better spatial organization
|
| 105 |
+
- **Value of 0**: Perfect alignment across all elements (rare in practice)
|
| 106 |
+
- **Typical range**: Varies based on layout complexity and density
|
| 107 |
+
- **Higher values**: More alignment violations, less organized layout
|
| 108 |
+
|
| 109 |
+
### Use Cases
|
| 110 |
+
|
| 111 |
+
- **Layout quality assessment**: Evaluate how well elements follow alignment principles
|
| 112 |
+
- **Generative model evaluation**: Compare alignment quality between different generation methods
|
| 113 |
+
- **Design feedback**: Identify layouts with poor spatial organization
|
| 114 |
+
|
| 115 |
+
### Key Insights
|
| 116 |
+
|
| 117 |
+
- **Professional designs** typically have lower non-alignment scores
|
| 118 |
+
- **Grid-based layouts** naturally achieve better alignment
|
| 119 |
+
- **Dense layouts** may have higher scores due to increased element interactions
|
| 120 |
+
- **Small violations** (near-alignments) are penalized more than obvious non-alignments
|
| 121 |
+
|
| 122 |
+
## Citations
|
| 123 |
+
|
| 124 |
+
```bibtex
|
| 125 |
+
@inproceedings{hsu2023posterlayout,
|
| 126 |
+
title{Posterlayout: A new benchmark and approach for content-aware visual-textual presentation layout},
|
| 127 |
+
author={Hsu, Hsiao Yuan and He, Xiangteng and Peng, Yuxin and Kong, Hao and Zhang, Qing},
|
| 128 |
+
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
|
| 129 |
+
pages={6018--6026},
|
| 130 |
+
year={2023}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
@article{li2020attribute,
|
| 134 |
+
title={Attribute-conditioned layout gan for automatic graphic design},
|
| 135 |
+
author={Li, Jianan and Yang, Jimei and Zhang, Jianming and Liu, Chang and Wang, Christina and Xu, Tingfa},
|
| 136 |
+
journal={IEEE Transactions on Visualization and Computer Graphics},
|
| 137 |
+
volume={27},
|
| 138 |
+
number={10},
|
| 139 |
+
pages={4039--4048},
|
| 140 |
+
year={2020},
|
| 141 |
+
publisher={IEEE}
|
| 142 |
+
}
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
## References
|
| 146 |
+
|
| 147 |
+
- **Paper**: [PosterLayout (Hsu et al., CVPR 2023)](https://arxiv.org/abs/2303.15937)
|
| 148 |
+
- **Paper**: [Attribute-Conditioned Layout GAN (Li et al., TVCG 2021)](https://arxiv.org/abs/2009.05284)
|
| 149 |
+
- **Reference Implementation**: [PosterLayout eval.py](https://github.com/PKU-ICST-MIPL/PosterLayout-CVPR2023/blob/main/eval.py#L306-L339)
|
| 150 |
+
|
| 151 |
+
## Related Metrics
|
| 152 |
+
|
| 153 |
+
- [Layout Alignment](../layout_alignment/): Measures positive alignment between elements
|
| 154 |
+
- [Layout Validity](../layout_validity/): Checks basic validity constraints
|
| 155 |
+
- [Layout Overlay](../layout_overlay/): Measures element overlap (excluding underlay)
|
requirements.txt
CHANGED
|
@@ -1,89 +1,134 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
requests
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file was autogenerated by uv via the following command:
|
| 2 |
+
# uv export --package layout_non_alignment --no-dev --no-hashes --format requirements-txt
|
| 3 |
+
aiohappyeyeballs==2.6.1
|
| 4 |
+
# via aiohttp
|
| 5 |
+
aiohttp==3.13.2
|
| 6 |
+
# via fsspec
|
| 7 |
+
aiosignal==1.4.0
|
| 8 |
+
# via aiohttp
|
| 9 |
+
anyio==4.12.0
|
| 10 |
+
# via httpx
|
| 11 |
+
attrs==25.4.0
|
| 12 |
+
# via aiohttp
|
| 13 |
+
certifi==2025.11.12
|
| 14 |
+
# via
|
| 15 |
+
# httpcore
|
| 16 |
+
# httpx
|
| 17 |
+
# requests
|
| 18 |
+
charset-normalizer==3.4.4
|
| 19 |
+
# via requests
|
| 20 |
+
click==8.3.1
|
| 21 |
+
# via typer-slim
|
| 22 |
+
colorama==0.4.6 ; sys_platform == 'win32'
|
| 23 |
+
# via
|
| 24 |
+
# click
|
| 25 |
+
# tqdm
|
| 26 |
+
datasets==4.4.2
|
| 27 |
+
# via evaluate
|
| 28 |
+
dill==0.4.0
|
| 29 |
+
# via
|
| 30 |
+
# datasets
|
| 31 |
+
# evaluate
|
| 32 |
+
# multiprocess
|
| 33 |
+
evaluate==0.4.6
|
| 34 |
+
# via layout-non-alignment
|
| 35 |
+
filelock==3.20.1
|
| 36 |
+
# via
|
| 37 |
+
# datasets
|
| 38 |
+
# huggingface-hub
|
| 39 |
+
frozenlist==1.8.0
|
| 40 |
+
# via
|
| 41 |
+
# aiohttp
|
| 42 |
+
# aiosignal
|
| 43 |
+
fsspec==2025.10.0
|
| 44 |
+
# via
|
| 45 |
+
# datasets
|
| 46 |
+
# evaluate
|
| 47 |
+
# huggingface-hub
|
| 48 |
+
h11==0.16.0
|
| 49 |
+
# via httpcore
|
| 50 |
+
hf-xet==1.2.0 ; platform_machine == 'AMD64' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'arm64' or platform_machine == 'x86_64'
|
| 51 |
+
# via huggingface-hub
|
| 52 |
+
httpcore==1.0.9
|
| 53 |
+
# via httpx
|
| 54 |
+
httpx==0.28.1
|
| 55 |
+
# via
|
| 56 |
+
# datasets
|
| 57 |
+
# huggingface-hub
|
| 58 |
+
huggingface-hub==1.2.3
|
| 59 |
+
# via
|
| 60 |
+
# datasets
|
| 61 |
+
# evaluate
|
| 62 |
+
idna==3.11
|
| 63 |
+
# via
|
| 64 |
+
# anyio
|
| 65 |
+
# httpx
|
| 66 |
+
# requests
|
| 67 |
+
# yarl
|
| 68 |
+
multidict==6.7.0
|
| 69 |
+
# via
|
| 70 |
+
# aiohttp
|
| 71 |
+
# yarl
|
| 72 |
+
multiprocess==0.70.18
|
| 73 |
+
# via
|
| 74 |
+
# datasets
|
| 75 |
+
# evaluate
|
| 76 |
+
numpy==2.2.6
|
| 77 |
+
# via
|
| 78 |
+
# datasets
|
| 79 |
+
# evaluate
|
| 80 |
+
# pandas
|
| 81 |
+
packaging==25.0
|
| 82 |
+
# via
|
| 83 |
+
# datasets
|
| 84 |
+
# evaluate
|
| 85 |
+
# huggingface-hub
|
| 86 |
+
pandas==2.3.3
|
| 87 |
+
# via
|
| 88 |
+
# datasets
|
| 89 |
+
# evaluate
|
| 90 |
+
propcache==0.4.1
|
| 91 |
+
# via
|
| 92 |
+
# aiohttp
|
| 93 |
+
# yarl
|
| 94 |
+
pyarrow==22.0.0
|
| 95 |
+
# via datasets
|
| 96 |
+
python-dateutil==2.9.0.post0
|
| 97 |
+
# via pandas
|
| 98 |
+
pytz==2025.2
|
| 99 |
+
# via pandas
|
| 100 |
+
pyyaml==6.0.3
|
| 101 |
+
# via
|
| 102 |
+
# datasets
|
| 103 |
+
# huggingface-hub
|
| 104 |
+
requests==2.32.5
|
| 105 |
+
# via
|
| 106 |
+
# datasets
|
| 107 |
+
# evaluate
|
| 108 |
+
shellingham==1.5.4
|
| 109 |
+
# via huggingface-hub
|
| 110 |
+
six==1.17.0
|
| 111 |
+
# via python-dateutil
|
| 112 |
+
tqdm==4.67.1
|
| 113 |
+
# via
|
| 114 |
+
# datasets
|
| 115 |
+
# evaluate
|
| 116 |
+
# huggingface-hub
|
| 117 |
+
typer-slim==0.21.0
|
| 118 |
+
# via huggingface-hub
|
| 119 |
+
typing-extensions==4.15.0
|
| 120 |
+
# via
|
| 121 |
+
# aiosignal
|
| 122 |
+
# anyio
|
| 123 |
+
# huggingface-hub
|
| 124 |
+
# typer-slim
|
| 125 |
+
tzdata==2025.3
|
| 126 |
+
# via pandas
|
| 127 |
+
urllib3==2.6.2
|
| 128 |
+
# via requests
|
| 129 |
+
xxhash==3.6.0
|
| 130 |
+
# via
|
| 131 |
+
# datasets
|
| 132 |
+
# evaluate
|
| 133 |
+
yarl==1.22.0
|
| 134 |
+
# via aiohttp
|