mediaattention 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mediaattention-0.2.0/.gitignore +5 -0
- mediaattention-0.2.0/CHANGELOG.md +32 -0
- mediaattention-0.2.0/CITATION.cff +14 -0
- mediaattention-0.2.0/LICENSE +202 -0
- mediaattention-0.2.0/PKG-INFO +243 -0
- mediaattention-0.2.0/README.md +195 -0
- mediaattention-0.2.0/mediaattention/__init__.py +41 -0
- mediaattention-0.2.0/mediaattention/bench.py +129 -0
- mediaattention-0.2.0/mediaattention/cli.py +69 -0
- mediaattention-0.2.0/mediaattention/detect.py +167 -0
- mediaattention-0.2.0/mediaattention/examples/ad.mp4 +0 -0
- mediaattention-0.2.0/mediaattention/examples/ad.png +0 -0
- mediaattention-0.2.0/mediaattention/memory.py +31 -0
- mediaattention-0.2.0/mediaattention/metrics.py +79 -0
- mediaattention-0.2.0/mediaattention/render.py +34 -0
- mediaattention-0.2.0/mediaattention/saliency.py +145 -0
- mediaattention-0.2.0/mediaattention/ui.py +179 -0
- mediaattention-0.2.0/mediaattention/unisal/LICENSE +201 -0
- mediaattention-0.2.0/mediaattention/unisal/__init__.py +7 -0
- mediaattention-0.2.0/mediaattention/unisal/model.py +579 -0
- mediaattention-0.2.0/mediaattention/unisal/models/MobileNetV2.py +224 -0
- mediaattention-0.2.0/mediaattention/unisal/models/__init__.py +0 -0
- mediaattention-0.2.0/mediaattention/unisal/models/cgru.py +424 -0
- mediaattention-0.2.0/mediaattention/unisal/utils.py +217 -0
- mediaattention-0.2.0/mediaattention/video.py +178 -0
- mediaattention-0.2.0/pyproject.toml +44 -0
- mediaattention-0.2.0/tests/test_metrics.py +188 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (2026-10-21)
|
|
4
|
+
|
|
5
|
+
**Default model**
|
|
6
|
+
- UNISAL (Apache-2.0) is now the default attention model, chosen by the eye-tracking benchmark: the most accurate openly licensed model, and ~17× faster than DeepGaze IIE. Weights are downloaded from [huggingface.co/pranikz/MediaAttention](https://huggingface.co/pranikz/MediaAttention).
|
|
7
|
+
- DeepGaze IIE is still supported (`--model deepgaze`), installed from source because it isn't on PyPI.
|
|
8
|
+
|
|
9
|
+
**Video**
|
|
10
|
+
- Video uses UNISAL's recurrent video mode by default; `--per-frame` keeps frame-by-frame scoring.
|
|
11
|
+
- AOIs are tracked through each shot with optical flow.
|
|
12
|
+
- Hard cuts are detected.
|
|
13
|
+
|
|
14
|
+
**Calibration (`bench`)**
|
|
15
|
+
- `bench` builds target ranges from a folder of your own ads.
|
|
16
|
+
- `--kpi` builds them from your best-performing ads instead, and reports which metrics track the KPI.
|
|
17
|
+
|
|
18
|
+
**Scores and UI**
|
|
19
|
+
- New memory score (ResMem, optional, non-commercial licence).
|
|
20
|
+
- Web UI (`mediaattention ui`) with Analyse and Calibrate tabs.
|
|
21
|
+
|
|
22
|
+
**Research**
|
|
23
|
+
- Eye-tracking benchmark of six open models (`benchmarks/`).
|
|
24
|
+
- Research report: `docs/research/MediaAttention-report.pdf`.
|
|
25
|
+
|
|
26
|
+
## 0.1.0 (2026-10-21)
|
|
27
|
+
|
|
28
|
+
- Attention heatmap and fog map: DeepGaze IIE, with a spectral-residual fallback.
|
|
29
|
+
- Scores: Focus, Cognitive Demand, AOI attention and lift, Impact Score.
|
|
30
|
+
- Automatic AOI detection: OCR plus OWLv2.
|
|
31
|
+
- Video scoring.
|
|
32
|
+
- CLI.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use MediaAttention, please cite it, and the papers behind the parts you rely on (see README)."
|
|
3
|
+
title: "MediaAttention: open-source attention prediction and creative scoring for ads"
|
|
4
|
+
type: software
|
|
5
|
+
authors:
|
|
6
|
+
- family-names: Mahapatra
|
|
7
|
+
given-names: Pratyush
|
|
8
|
+
website: "https://pranikz.dev"
|
|
9
|
+
version: 0.2.0
|
|
10
|
+
date-released: 2026-10-21
|
|
11
|
+
license: Apache-2.0
|
|
12
|
+
repository-code: "https://github.com/pranikz/MediaAttention"
|
|
13
|
+
url: "https://pranikz.github.io/MediaAttention/"
|
|
14
|
+
keywords: [saliency, eye-tracking, visual attention, advertising]
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mediaattention
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Open-source attention prediction and creative scoring for image and video ads
|
|
5
|
+
Project-URL: Homepage, https://pranikz.github.io/MediaAttention/
|
|
6
|
+
Project-URL: Repository, https://github.com/pranikz/MediaAttention
|
|
7
|
+
Project-URL: Model, https://huggingface.co/pranikz/MediaAttention
|
|
8
|
+
Project-URL: Report, https://github.com/pranikz/MediaAttention/blob/main/docs/research/MediaAttention-report.pdf
|
|
9
|
+
Project-URL: Changelog, https://github.com/pranikz/MediaAttention/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Pratyush Mahapatra
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
License-File: mediaattention/unisal/LICENSE
|
|
14
|
+
Keywords: advertising,computer-vision,eye-tracking,marketing,saliency,visual-attention
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: pillow
|
|
22
|
+
Requires-Dist: scipy
|
|
23
|
+
Provides-Extra: all
|
|
24
|
+
Requires-Dist: av; extra == 'all'
|
|
25
|
+
Requires-Dist: gradio; extra == 'all'
|
|
26
|
+
Requires-Dist: huggingface-hub; extra == 'all'
|
|
27
|
+
Requires-Dist: opencv-python-headless; extra == 'all'
|
|
28
|
+
Requires-Dist: rapidocr-onnxruntime; extra == 'all'
|
|
29
|
+
Requires-Dist: torch; extra == 'all'
|
|
30
|
+
Requires-Dist: transformers; extra == 'all'
|
|
31
|
+
Provides-Extra: aoi
|
|
32
|
+
Requires-Dist: rapidocr-onnxruntime; extra == 'aoi'
|
|
33
|
+
Requires-Dist: torch; extra == 'aoi'
|
|
34
|
+
Requires-Dist: transformers; extra == 'aoi'
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
37
|
+
Provides-Extra: memory
|
|
38
|
+
Requires-Dist: resmem; extra == 'memory'
|
|
39
|
+
Provides-Extra: ui
|
|
40
|
+
Requires-Dist: gradio; extra == 'ui'
|
|
41
|
+
Provides-Extra: unisal
|
|
42
|
+
Requires-Dist: huggingface-hub; extra == 'unisal'
|
|
43
|
+
Requires-Dist: torch; extra == 'unisal'
|
|
44
|
+
Provides-Extra: video
|
|
45
|
+
Requires-Dist: av; extra == 'video'
|
|
46
|
+
Requires-Dist: opencv-python-headless; extra == 'video'
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
# MediaAttention
|
|
50
|
+
|
|
51
|
+
**Site:** https://pranikz.github.io/MediaAttention/ · **Model on Hugging Face:** https://huggingface.co/pranikz/MediaAttention · **Research report (PDF):** [docs/research/MediaAttention-report.pdf](docs/research/MediaAttention-report.pdf)
|
|
52
|
+
|
|
53
|
+
Open-source predicted attention for ads and media. Give it an image or video creative and it predicts where people will look, then scores it:
|
|
54
|
+
|
|
55
|
+
- **Attention heatmap and fog map**: where the eye lands in the first seconds
|
|
56
|
+
- **Focus** (0–100): attention on a few elements (high) vs. scattered everywhere (low)
|
|
57
|
+
- **Cognitive Demand** (0–100): visual complexity, measured as local Shannon entropy
|
|
58
|
+
- **Memory** (0–100, optional): predicted share of viewers who would recognise the creative after a brief exposure
|
|
59
|
+
- **AOI attention**: % of attention on brand, product, headline and CTA, plus *lift* (attention share ÷ area share)
|
|
60
|
+
- **Impact Score** (1–10): each metric is scored against a recommended range, then averaged
|
|
61
|
+
|
|
62
|
+
It's an open alternative to proprietary "neuro-prediction" tools. The methods are documented and the numbers are reproducible.
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install "mediaattention[all]" # UNISAL model, AOI detection, video, web UI (recommended)
|
|
68
|
+
pip install mediaattention # core only: spectral-residual fallback, no ML dependencies
|
|
69
|
+
pip install "mediaattention[memory]" # + memory score (ResMem). NON-COMMERCIAL license, see Licenses
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Or from source: `git clone https://github.com/pranikz/MediaAttention && pip install -e ".[all]"`. The extras can also be installed one at a time: `unisal`, `aoi`, `video`, `ui`, `memory`.
|
|
73
|
+
|
|
74
|
+
DeepGaze IIE (optional, `--model deepgaze`) isn't on PyPI. Install it from source:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install torch torchvision einops clip-anytorch "deepgaze_pytorch @ git+https://github.com/matthias-k/DeepGaze"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
When ResMem is installed, `memory` is added to every report automatically. Videos also get `memory_start` / `memory_end`.
|
|
81
|
+
|
|
82
|
+
## Use
|
|
83
|
+
|
|
84
|
+
### Web UI
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
mediaattention ui # opens http://localhost:7860
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Drop in an image or video (or click one of the built-in examples), optionally name the product, and hit **Analyse**. You get:
|
|
91
|
+
|
|
92
|
+
- the Impact Score with a verdict
|
|
93
|
+
- every metric with its 1–10 score and target range
|
|
94
|
+
- the AOI table
|
|
95
|
+
- heatmap, fog map and AOI overlay for images; heatmap video and a Focus/Cognitive Demand/Memory timeline for videos
|
|
96
|
+
- `scores.json` to download
|
|
97
|
+
|
|
98
|
+
The **Calibrate** tab does `bench` in the browser: upload a batch of ads from one category (select many files) and it builds the target ranges, shows them, and loads them into the Analyse tab. You can also download that `benchmarks.json`, or upload one under *Options* in the Analyse tab. Everything runs on your machine. `--share` creates a temporary public link if you want to show someone.
|
|
99
|
+
|
|
100
|
+
### Command line
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
mediaattention ad.png --aoi auto --product "a running shoe" --out report/
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This writes `report/heat.png`, `report/fog.png`, `report/aois.png` (heatmap with each AOI boxed and its attention %) and `report/scores.json`:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"model": "unisal",
|
|
111
|
+
"metrics": {"focus": 64.2, "cognitive_demand": 38.5, "brand_attention": 12.1},
|
|
112
|
+
"aois": [{"label": "brand", "box": [0.05, 0.04, 0.3, 0.14], "attention_pct": 12.1, "area_pct": 3.5, "lift": 3.46}],
|
|
113
|
+
"impact_score": 10.0,
|
|
114
|
+
"impact_parts": {"focus": 10.0, "cognitive_demand": 10.0, "brand_attention": 10.0}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The example values are illustrative.
|
|
119
|
+
|
|
120
|
+
### Calibrate the Impact Score on your own ads
|
|
121
|
+
|
|
122
|
+
The default recommended ranges are placeholders. Build real ones from a folder of creatives, ideally one folder per industry or use case with 30+ assets each:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
mediaattention bench ads/fmcg-social/ --aoi auto --out bench/
|
|
126
|
+
mediaattention new_ad.png --aoi auto --benchmarks bench/benchmarks.json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`bench` scores every image and video in the folder and writes `assets.jsonl` (one line of metrics per asset) and `benchmarks.json`:
|
|
130
|
+
|
|
131
|
+
- **Higher-is-better metrics** (Focus, attention on brand, product, headline and CTA): the recommended range is the top 20%.
|
|
132
|
+
- **Cognitive Demand:** the middle 50%, because moderate complexity works best.
|
|
133
|
+
- **Body-text attention:** excluded, because it doesn't predict results.
|
|
134
|
+
|
|
135
|
+
**Have campaign results?** Pass them in and the targets come from your best-*performing* ads instead of your best-*scoring* ones:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
mediaattention bench ads/fmcg-social/ --aoi auto --kpi results.csv --kpi-column ctr --out bench/
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- **Format:** `results.csv` has a `file` column (the ad's filename, or its path inside the folder) plus KPI columns such as `ctr`, `recall` or `cpc`. Add `--kpi-lower-better` for costs like CPC or CPA.
|
|
142
|
+
- **Targets:** each metric's target becomes the middle 50% of what your top 20% of ads by that KPI scored.
|
|
143
|
+
- **`kpi_report.json`:** shows which metrics actually track the KPI for your ads (Spearman ρ and p-value).
|
|
144
|
+
- **Web UI:** the Calibrate tab takes the same CSV.
|
|
145
|
+
- **Size:** you need at least 25 ads with a KPI, so there are 5 winners.
|
|
146
|
+
|
|
147
|
+
### Video
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
mediaattention ad.mp4 --aoi auto --product "a running shoe" --fps 2 --out report/
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
This writes `report/heat.mp4` (the heatmap and AOIs on every scored frame) and `report/scores.json`. The JSON has a summary plus a per-frame `timeline`:
|
|
154
|
+
|
|
155
|
+
- Attention comes from UNISAL's **video mode**: a recurrent model fed ~6 frames per second, so attention carries over from frame to frame as in real viewing. `--per-frame` scores frames independently instead (any `--model`), averaged over the last second.
|
|
156
|
+
- `cuts`: hard scene cuts in seconds. Key messages placed right after a cut are easily forgotten.
|
|
157
|
+
- `focus_start` / `focus_end`: Focus over the first and last 2 seconds.
|
|
158
|
+
- Per AOI: `total_attention` (share over the whole video), `relative_attention` (share while on screen) and `availability_s` (seconds on screen).
|
|
159
|
+
|
|
160
|
+
You can also pass your own AOIs (`--aoi aois.json`, as `[{"label": "brand", "box": [x0, y0, x1, y1]}]` in 0–1 coords) and your own recommended ranges (`--benchmarks ranges.json`, as `{"focus": [60, 100]}`).
|
|
161
|
+
|
|
162
|
+
From Python:
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from PIL import Image
|
|
166
|
+
from mediaattention import score
|
|
167
|
+
heat, report = score(Image.open("ad.png")) # model="unisal" by default; "deepgaze" or "spectral" also work
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## How each number is computed
|
|
171
|
+
|
|
172
|
+
| Metric | Method |
|
|
173
|
+
|---|---|
|
|
174
|
+
| Heatmap | UNISAL (Droste et al., ECCV 2020) with its SALICON weights, downloaded on first use from [pranikz/MediaAttention](https://huggingface.co/pranikz/MediaAttention). Optional: DeepGaze IIE with a Gaussian centre-bias prior. Fallback: spectral residual (Hou & Zhang 2007). |
|
|
175
|
+
| Focus | Share of the image needed to hold 80% of predicted attention, mapped to 0–100 (an attention-dispersion measure). |
|
|
176
|
+
| Cognitive Demand | Mean Shannon entropy of 16×16 blocks of the grayscale image (32 levels), normalized to 0–100. |
|
|
177
|
+
| Memory | ResMem (Needell & Bainbridge 2022), trained on LaMem/MemCat recognition data. It predicts the share of people who recognise an image when it repeats in a rapid stream, the same game Neurons' memory model is built on. Scores cluster high (a plain grey image gets ~81, ads ~90–98), so compare within a `bench` corpus rather than reading absolute values. Videos are scored per frame, without audio. |
|
|
178
|
+
| AOI detection | OCR (RapidOCR) reads every text line. A short line on a solid colour patch is the CTA, and the box grows out to the button's edges. The largest text is the headline, and the rest is body. Logo and product come from OWLv2 zero-shot detection (`--product` says what to look for). If OWLv2 is unsure about the logo, a short text line in the top or bottom band is used instead. |
|
|
179
|
+
| AOI attention % | Sum of heatmap mass inside the box. |
|
|
180
|
+
| Video | Frames are sampled at `--fps` for scoring. With UNISAL, attention comes from its recurrent video mode (DHF1K weights), fed at ~6 fps with its state carried across the whole video. With `--per-frame` or an image model, each sampled frame is scored on its own and heatmaps are averaged over the last second, so attention lingers briefly after a cut. A cut is a jump of more than 40% in the grayscale histogram between consecutive frames, with a 0.5 s minimum shot length. Auto AOIs are detected at the start of each shot, then tracked through every frame with Lucas–Kanade optical flow. Each box gets its own shift and zoom, so camera moves and moving objects are both followed. AOIs from a JSON file stay fixed for the whole video. |
|
|
181
|
+
| Impact Score | 10 inside the recommended range; outside, it falls linearly from 7 at the edge to 1 at the end of the scale. The final score is the mean over available metrics, and missing AOIs are skipped. |
|
|
182
|
+
|
|
183
|
+
## Benchmark
|
|
184
|
+
|
|
185
|
+
How close are the predictions to where real people look? We scored six open attention models against human eye tracking on **FiWI** (Shen & Zhao, ECCV 2014): 149 webpages, 11 viewers, 5 s free viewing. None of the models was trained on it. All metrics were computed with pysaliency on an Apple M3 Pro. The method and the script are in [`benchmarks/`](benchmarks/). Rebuild the tables with `python benchmarks/table.py fiwi`.
|
|
186
|
+
|
|
187
|
+
| Model | CC ↑ | NSS ↑ | sAUC ↑ | AUC ↑ | SIM ↑ | KLD ↓ | s / image (M3 Pro) | Licence |
|
|
188
|
+
|---|---|---|---|---|---|---|---|---|
|
|
189
|
+
| DeepGaze MSDB | 0.676 | 1.54 | 0.748 | 0.840 | 0.642 | 0.462 | 2.90 | no licence file |
|
|
190
|
+
| DeepGaze IIE | 0.649 | 1.50 | 0.729 | 0.824 | 0.629 | 0.504 | 0.67 | no licence file |
|
|
191
|
+
| **UNISAL (default)** | 0.616 | 1.31 | 0.661 | 0.796 | 0.613 | 0.575 | 0.04 | Apache-2.0 |
|
|
192
|
+
| TranSalNet-Dense | 0.608 | 1.25 | 0.646 | 0.788 | 0.605 | 0.603 | 0.10 | MIT |
|
|
193
|
+
| Centre-bias baseline | 0.345 | 0.62 | 0.500 | 0.676 | 0.476 | 0.899 | 0.01 | – |
|
|
194
|
+
| Spectral residual (fallback) | 0.209 | 0.40 | 0.562 | 0.633 | 0.449 | 1.052 | 0.00 | – |
|
|
195
|
+
|
|
196
|
+
Correlation (CC) with human attention, by page type:
|
|
197
|
+
|
|
198
|
+
| Model | Mixed | Pictorial | Text |
|
|
199
|
+
|---|---|---|---|
|
|
200
|
+
| DeepGaze MSDB | 0.686 | 0.751 | 0.592 |
|
|
201
|
+
| DeepGaze IIE | 0.680 | 0.726 | 0.541 |
|
|
202
|
+
| **UNISAL (default)** | 0.641 | 0.676 | 0.531 |
|
|
203
|
+
| TranSalNet-Dense | 0.642 | 0.650 | 0.532 |
|
|
204
|
+
|
|
205
|
+
What this means:
|
|
206
|
+
|
|
207
|
+
- **UNISAL is the default.** It is the most accurate model with a permissive licence, and by far the fastest: 0.04 s per image, ~17× faster than DeepGaze IIE.
|
|
208
|
+
- **DeepGaze MSDB is the most accurate** on every metric, ~0.06 CC ahead, but 70× slower and with no licence file. DeepGaze IIE stays available as an option (`--model deepgaze`).
|
|
209
|
+
- **Text-heavy layouts are the hardest case for every model.** This is where ad-specific training data would help most.
|
|
210
|
+
|
|
211
|
+
The full write-up, including a review of 15 commercial tools and what their accuracy claims actually measure, is in the [research report (PDF)](docs/research/MediaAttention-report.pdf). An ad and poster benchmark on UEyes (CHI 2023) is in progress.
|
|
212
|
+
|
|
213
|
+
## Honest limitations
|
|
214
|
+
|
|
215
|
+
- The attention model is trained on public natural-image eye-tracking data (SALICON; DHF1K for video), not ads. Expect it to be weaker on text-heavy creatives than an ad-specific model.
|
|
216
|
+
- **The default recommended ranges are placeholders.** Run `bench` on your own ads to calibrate them. Without `--kpi`, `bench` ranks assets by the metric itself, not by real results. Pass campaign KPIs (CTR, recall) when you have them.
|
|
217
|
+
- AOI detection relies on layout rules. Ads that break them (a headline smaller than the body text, an outlined ghost button, a logo in the middle of the ad) need `--aoi aois.json`.
|
|
218
|
+
- **Video mode is not yet validated on ad video.** Published results on TV ads favour video models over frame-by-frame prediction (CC 0.56 vs 0.23, Ye & Wedel 2026), but UNISAL's video mode hasn't been benchmarked on ad eye tracking here. Use `--per-frame` to compare. Video has no audio model.
|
|
219
|
+
- No emotion, engagement or trust scores yet. These need human response data, which nobody has released openly so far (see the roadmap).
|
|
220
|
+
|
|
221
|
+
## Roadmap
|
|
222
|
+
|
|
223
|
+
- [x] Video: per-frame scoring, first/last-2s windows, scene-cut detection
|
|
224
|
+
- [x] Video: track AOIs within a shot
|
|
225
|
+
- [x] `mediaattention bench <folder>`: build recommended ranges from your own corpus
|
|
226
|
+
- [x] `bench --kpi`: targets from your best-performing ads, plus which metrics track the KPI
|
|
227
|
+
- [x] Memory score (ResMem)
|
|
228
|
+
- [ ] Commercial-friendly memory model (retrain on openly licensed data)
|
|
229
|
+
- [x] Eye-tracking benchmark of the open models (FiWI webpages; see Benchmark)
|
|
230
|
+
- [ ] Ad and poster benchmark on UEyes (in progress)
|
|
231
|
+
- [x] Permissive default model: UNISAL (Apache-2.0), chosen by the benchmark
|
|
232
|
+
- [ ] Open data-collection kit: webcam eye-tracking plus timed Yes/No response tests, so the community can build ad-specific and emotion models
|
|
233
|
+
|
|
234
|
+
## Licenses
|
|
235
|
+
|
|
236
|
+
The code is Apache-2.0. Model weights are downloaded at runtime and keep their own terms:
|
|
237
|
+
|
|
238
|
+
- **UNISAL** (default) is Apache-2.0. Its model code is vendored in `mediaattention/unisal/` with its licence, and its weights are redistributed unchanged on Hugging Face with a NOTICE.
|
|
239
|
+
- **DeepGaze IIE has no license file** in its repository, which by default means all rights reserved. It's an optional extra and is downloaded from the authors at runtime, never redistributed here. Ask the authors before commercial use. Its weights are trained on SALICON/MIT1003.
|
|
240
|
+
- OWLv2, RapidOCR and OpenCV are Apache-2.0. PyAV is BSD-3-Clause.
|
|
241
|
+
- **ResMem is non-commercial only** (University of Chicago license). Research use, including inside a company, is fine. Using it in a commercial product needs permission from the Brain Bridge Lab. It's an optional extra, so nothing else depends on it.
|
|
242
|
+
|
|
243
|
+
Check the dataset terms before any commercial use.
|