CyberDancer commited on
Commit
2ecd785
·
verified ·
1 Parent(s): ad60733

Add IBCBench queries, metadata, and dataset card

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. LICENSE +201 -0
  2. README.md +178 -0
  3. download_images.py +316 -0
  4. metadata/10287726@N02.jsonl +0 -0
  5. metadata/10297518@N00.jsonl +0 -0
  6. metadata/10299779@N03.jsonl +0 -0
  7. metadata/12276997@N06.jsonl +0 -0
  8. metadata/12734746@N00.jsonl +0 -0
  9. metadata/13101981@N03.jsonl +0 -0
  10. metadata/14580956@N08.jsonl +0 -0
  11. metadata/14737255@N00.jsonl +0 -0
  12. metadata/14798958@N08.jsonl +0 -0
  13. metadata/15352839@N00.jsonl +0 -0
  14. metadata/15803691@N00.jsonl +0 -0
  15. metadata/18383978@N00.jsonl +0 -0
  16. metadata/21435131@N06.jsonl +0 -0
  17. metadata/21895046@N08.jsonl +0 -0
  18. metadata/22017657@N05.jsonl +0 -0
  19. metadata/22526649@N03.jsonl +0 -0
  20. metadata/22736462@N07.jsonl +0 -0
  21. metadata/23090753@N06.jsonl +0 -0
  22. metadata/23518714@N00.jsonl +0 -0
  23. metadata/23736466@N00.jsonl +0 -0
  24. metadata/24232779@N00.jsonl +0 -0
  25. metadata/24413182@N00.jsonl +0 -0
  26. metadata/24468935@N03.jsonl +0 -0
  27. metadata/24736216@N07.jsonl +0 -0
  28. metadata/24819841@N06.jsonl +0 -0
  29. metadata/25367139@N00.jsonl +0 -0
  30. metadata/25652622@N00.jsonl +0 -0
  31. metadata/25899413@N04.jsonl +0 -0
  32. metadata/27550543@N02.jsonl +0 -0
  33. metadata/27634886@N00.jsonl +0 -0
  34. metadata/27637456@N06.jsonl +0 -0
  35. metadata/28157992@N03.jsonl +0 -0
  36. metadata/28495173@N00.jsonl +0 -0
  37. metadata/30872191@N00.jsonl +0 -0
  38. metadata/31058815@N00.jsonl +0 -0
  39. metadata/35032604@N00.jsonl +0 -0
  40. metadata/39979407@N05.jsonl +0 -0
  41. metadata/40817698@N07.jsonl +0 -0
  42. metadata/41610421@N05.jsonl +0 -0
  43. metadata/41838028@N00.jsonl +0 -0
  44. metadata/43145783@N00.jsonl +0 -0
  45. metadata/47554402@N00.jsonl +0 -0
  46. metadata/47642109@N04.jsonl +0 -0
  47. metadata/49475364@N00.jsonl +0 -0
  48. metadata/49645113@N07.jsonl +0 -0
  49. metadata/54368512@N00.jsonl +0 -0
  50. metadata/55772206@N03.jsonl +0 -0
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
README.md ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: IBCBench
3
+ language:
4
+ - en
5
+ license: other
6
+ task_categories:
7
+ - other
8
+ tags:
9
+ - image-retrieval
10
+ - multi-image-retrieval
11
+ - multimodal-agents
12
+ - image-bundle-composition
13
+ - visual-history
14
+ - yfcc100m
15
+ configs:
16
+ - config_name: default
17
+ data_files:
18
+ - split: test
19
+ path: queries.jsonl
20
+ ---
21
+
22
+ # IBCBench: Image Bundle Composition Benchmark
23
+
24
+ IBCBench is the benchmark introduced in **Weaving Visual Narratives: Agentic Image Bundle Composition Beyond Atomic Visual Matching**, accepted to the **EMNLP 2026 Main Conference**.
25
+
26
+ [**GitHub**](https://github.com/LaVieEnRose365/Image-Bundle-Composition)
27
+
28
+ ## Overview
29
+
30
+ Image Bundle Composition (IBC) shifts image retrieval from independently ranking images to dynamically composing a compact, cohesive bundle whose images jointly satisfy relational, temporal, spatial, or narrative constraints. The target bundles are not predefined in the image pool, so systems must reason over non-decomposable bundle-level relevance in a combinatorial search space.
31
+
32
+ IBCBench contains **667 human-verified queries** evaluated against a pool of **109,467 images from 57 users**. Each ground-truth bundle contains 3--5 images. The benchmark was built using a semi-automated candidate mining and verification pipeline followed by expert human review.
33
+
34
+ ## Dataset Statistics
35
+
36
+ | Statistic | Value |
37
+ |:--|--:|
38
+ | Queries | 667 |
39
+ | Images | 109,467 |
40
+ | Users | 57 |
41
+ | Bundle size: 3 images | 162 (24.3%) |
42
+ | Bundle size: 4 images | 215 (32.2%) |
43
+ | Bundle size: 5 images | 290 (43.5%) |
44
+ | Same-location dynamics | 52.5% |
45
+ | Cross-location structures | 47.5% |
46
+
47
+ ## Download
48
+
49
+ Download the complete benchmark from the Hugging Face Hub:
50
+
51
+ ```bash
52
+ hf download CyberDancer/IBCBench --repo-type dataset --local-dir IBCBench
53
+ ```
54
+
55
+ Then extract the image pool:
56
+
57
+ ```bash
58
+ unzip IBCBench/images.zip -d IBCBench
59
+ ```
60
+
61
+ Alternatively, the included `download_images.py` script can reconstruct the image pool from `photo_ids/`:
62
+
63
+ ```bash
64
+ python IBCBench/download_images.py \
65
+ --photo-ids-path IBCBench/photo_ids \
66
+ --images-path IBCBench/images
67
+ ```
68
+
69
+ ## File Structure
70
+
71
+ ```text
72
+ IBCBench/
73
+ ├── queries.jsonl # 667 IBC queries and ground-truth bundles
74
+ ├── metadata/
75
+ │ └── {user_id}.jsonl # Photo metadata for each user
76
+ ├── photo_ids/
77
+ │ └── {user_id}.txt # Photo IDs and storage hashes for each user
78
+ ├── images.zip # images/{user_id}/{photo_id}.jpg
79
+ └── download_images.py # Alternative image downloader
80
+ ```
81
+
82
+ ## Query Format
83
+
84
+ Each line in `queries.jsonl` is one query and its ground-truth image bundle:
85
+
86
+ ```json
87
+ {
88
+ "query_id": "10287726@N02_s18_w0_n3",
89
+ "query": "Find a bundle documenting the same spectator's Olympic viewing experience: ...",
90
+ "image_ids": ["7797992908", "7797994344", "7797998284"]
91
+ }
92
+ ```
93
+
94
+ | Field | Type | Description |
95
+ |:--|:--|:--|
96
+ | `query_id` | string | Unique query identifier. Its prefix is the YFCC user ID. |
97
+ | `query` | string | Natural-language bundle query in English. |
98
+ | `image_ids` | list[string] | Ground-truth set of 3--5 YFCC photo IDs. |
99
+
100
+ ## Photo Metadata Format
101
+
102
+ Each line in `metadata/{user_id}.jsonl` describes one image:
103
+
104
+ ```json
105
+ {
106
+ "photo_id": "4517621778",
107
+ "metadata": {
108
+ "taken_time": "2010-04-10 13:52:57",
109
+ "longitude": -1.239802,
110
+ "latitude": 51.754123,
111
+ "accuracy": 16.0,
112
+ "address": "...",
113
+ "capturedevice": "Panasonic DMC-TZ5"
114
+ }
115
+ }
116
+ ```
117
+
118
+ The location, address, accuracy, and capture-device fields are optional and may be absent. Album identifiers are intentionally excluded from the benchmark.
119
+
120
+ Each non-empty line in `photo_ids/{user_id}.txt` has the following tab-separated form:
121
+
122
+ ```text
123
+ {photo_id}\t{storage_hash}
124
+ ```
125
+
126
+ ## Shared Image Pool and Attribution
127
+
128
+ IBCBench uses the same image pool, metadata, and photo-ID mapping as [DISBench](https://huggingface.co/datasets/RUC-NLPIR/DISBench), which is derived from the public [YFCC100M](https://multimediacommons.wordpress.com/yfcc100m-core-dataset/) collection. IBCBench contributes a separate set of 667 queries and ground-truth bundles for the Image Bundle Composition task.
129
+
130
+ Please also cite DISBench and YFCC100M when using the shared image pool.
131
+
132
+ ## Ethical Considerations
133
+
134
+ The source images were publicly distributed under Creative Commons licenses. IBCBench is intended for research on multimodal retrieval and relational reasoning, particularly user-centric organization of personal photo collections. It is not intended for unauthorized surveillance, identity profiling, or analysis of private third-party collections.
135
+
136
+ Although the source media is public, the benchmark includes spatiotemporal metadata. Users should handle this information responsibly and follow the terms attached to each original image.
137
+
138
+ ## License
139
+
140
+ The IBCBench query annotations and BundleWeaver project are released under the [Apache License 2.0](https://github.com/LaVieEnRose365/Image-Bundle-Composition/blob/main/LICENSE). The images retain the individual Creative Commons licenses attached to the corresponding YFCC100M records; downstream users are responsible for checking and following those terms. The included DISBench-derived helper and shared files retain their upstream terms.
141
+
142
+ ## Citation
143
+
144
+ ```bibtex
145
+ @inproceedings{shan2026weaving,
146
+ title = {Weaving Visual Narratives: Agentic Image Bundle Composition Beyond Atomic Visual Matching},
147
+ author = {Shan, Rong and Xu, Tianyi and Zheng, Congmin and Chen, Wenteng and Zhu, Jiachen and Wu, Junjie and Zeng, Dun and Wang, Teng and Liu, Weiwen and Zhang, Changwang and Zhang, Weinan and Wang, Jun and Lin, Jianghao},
148
+ booktitle = {Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing},
149
+ year = {2026}
150
+ }
151
+ ```
152
+
153
+ DISBench:
154
+
155
+ ```bibtex
156
+ @misc{deng2026deepimagesearch,
157
+ title = {DeepImageSearch: Benchmarking Multimodal Agents for Context-Aware Image Retrieval in Visual Histories},
158
+ author = {Deng, Chenlong and Deng, Mengjie and Wu, Junjie and Zeng, Dun and Wang, Teng and Xie, Qingsong and Huang, Jiadeng and Ma, Shengjie and Zhang, Changwang and Wang, Zhaoxiang and Wang, Jun and Zhu, Yutao and Dou, Zhicheng},
159
+ year = {2026},
160
+ eprint = {2602.10809},
161
+ archivePrefix = {arXiv},
162
+ primaryClass = {cs.CV}
163
+ }
164
+ ```
165
+
166
+ YFCC100M:
167
+
168
+ ```bibtex
169
+ @article{thomee2016yfcc100m,
170
+ title = {YFCC100M: The New Data in Multimedia Research},
171
+ author = {Thomee, Bart and Shamma, David A. and Friedland, Gerald and Elizalde, Benjamin and Ni, Karl and Poland, Douglas and Borth, Damian and Li, Li-Jia},
172
+ journal = {Communications of the ACM},
173
+ volume = {59},
174
+ number = {2},
175
+ pages = {64--73},
176
+ year = {2016}
177
+ }
178
+ ```
download_images.py ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ fetch photos of selected users from yfcc.
3
+
4
+ arguments:
5
+ --dataset-path: path to the DISBench dataset
6
+ --max-workers: maximum number of worker threads for downloading
7
+ --clear: if set, the downloaded status will be cleared and you can start downloading from scratch.
8
+
9
+ input:
10
+ - DISBench/photo_ids/<uid>.txt
11
+ - each line: {photo_id}\t{hash} or {photo_id}\t{hash}\t{status}
12
+
13
+ output:
14
+ - DISBench/images/<uid>/{photo_id}.jpg
15
+ - DISBench/photo_ids/<uid>.txt
16
+ - each line: {photo_id}\t{hash}\t{status}
17
+
18
+ description:
19
+ - read the photo ids file, and get the photo ids, hashes, and statuses.
20
+ - if clear is set, clear the status, save the file.
21
+ - for each photo, if the status is:
22
+ - "valid": skip this.
23
+ - "success": try to load this file, if the file is valid, set the status to "valid". else, set the status to "error".
24
+ - "error" or None: try to download this photo again.
25
+ - download photos from s3.
26
+ - url: https://multimedia-commons.s3-us-west-2.amazonaws.com/data/images/<first 3 chars in hash>/<next 3 chars in hash>/<hash>.jpg. for example, if the hash is 00024a73d1a4c32fb29732d56a2, the url is https://multimedia-commons.s3-us-west-2.amazonaws.com/data/images/000/24a/00024a73d1a4c32fb29732d56a2.jpg.
27
+ - save the photo to the photos folder.
28
+ - download with multithreading, workers set to 16 in main().
29
+ - if download is successful, set the status to "success". else, set the status to "error".
30
+ - save the status to the photo ids file for each user.
31
+ """
32
+ import argparse
33
+ import os
34
+ import time
35
+ import requests
36
+ from pathlib import Path
37
+ from tqdm import tqdm
38
+ from concurrent.futures import ThreadPoolExecutor, as_completed
39
+ from PIL import Image
40
+
41
+
42
+ def construct_s3_url(hash_value):
43
+ """Construct S3 URL from hash value"""
44
+ # Get first 3 chars and next 3 chars
45
+ first_3 = hash_value[:3]
46
+ next_3 = hash_value[3:6]
47
+ return f"https://multimedia-commons.s3-us-west-2.amazonaws.com/data/images/{first_3}/{next_3}/{hash_value}.jpg"
48
+
49
+
50
+ def validate_image_file(image_path):
51
+ """Validate if an image file exists and can be loaded"""
52
+ if not image_path.exists():
53
+ return False
54
+ try:
55
+ with Image.open(image_path) as img:
56
+ img.load()
57
+ return True
58
+ except Exception:
59
+ return False
60
+
61
+
62
+ def download_photo(photo_id, hash_value, output_path, uid):
63
+ """Download a single photo from S3 with retry logic"""
64
+ max_retries = 4
65
+ last_error = None
66
+
67
+ for attempt in range(max_retries):
68
+ try:
69
+ url = construct_s3_url(hash_value)
70
+ response = requests.get(url, timeout=30, stream=True)
71
+ response.raise_for_status()
72
+
73
+ # Save the photo
74
+ output_path.parent.mkdir(parents=True, exist_ok=True)
75
+ with open(output_path, 'wb') as f:
76
+ for chunk in response.iter_content(chunk_size=8192):
77
+ f.write(chunk)
78
+
79
+ return photo_id, "success", None
80
+ except Exception as e:
81
+ last_error = e
82
+ # Retry for other errors
83
+ if attempt < max_retries - 1:
84
+ time.sleep(1) # Brief delay before retry
85
+ continue
86
+ return photo_id, "error", str(e)
87
+
88
+ # If we exhausted all retries, return the last error
89
+ return photo_id, "error", str(last_error) if last_error else "Unknown error after retries"
90
+
91
+
92
+ def process_photo_ids_file(photo_ids_file, photos_base_dir, uid):
93
+ """Process a single photo_ids file and return tasks and photo records"""
94
+ photos_dir = photos_base_dir / uid
95
+ photos_dir.mkdir(parents=True, exist_ok=True)
96
+
97
+ # Read all photo records
98
+ photo_records = [] # List of (photo_id, hash, status)
99
+ tasks = [] # List of (photo_id, hash, output_path) for photos to download
100
+ has_updates = False # Track if any status was updated
101
+
102
+ with open(photo_ids_file, 'r', encoding='utf-8') as f:
103
+ for line in f:
104
+ line = line.strip()
105
+ if not line:
106
+ continue
107
+
108
+ parts = line.split('\t')
109
+ if len(parts) < 2:
110
+ continue
111
+
112
+ photo_id = parts[0].strip()
113
+ hash_value = parts[1].strip()
114
+ status = parts[2].strip() if len(parts) >= 3 else None
115
+
116
+ if not photo_id or not hash_value:
117
+ continue
118
+
119
+ output_path = photos_dir / f"{photo_id}.jpg"
120
+
121
+ # Store the record
122
+ photo_records.append({
123
+ 'photo_id': photo_id,
124
+ 'hash': hash_value,
125
+ 'status': status,
126
+ 'output_path': output_path
127
+ })
128
+
129
+ # Process based on status according to description:
130
+ # - "valid": skip this
131
+ if status == "valid":
132
+ continue
133
+
134
+ # - "success": try to load this file, if valid set to "valid", else set to "error"
135
+ if status == "success":
136
+ if validate_image_file(output_path):
137
+ photo_records[-1]['status'] = "valid"
138
+ has_updates = True
139
+ else:
140
+ photo_records[-1]['status'] = "error"
141
+ has_updates = True
142
+ # Need to download again
143
+ tasks.append((photo_id, hash_value, output_path))
144
+ continue
145
+
146
+ # - "error" or None: try to download this photo again
147
+ if status == "error" or status is None:
148
+ tasks.append((photo_id, hash_value, output_path))
149
+
150
+ return tasks, photo_records, has_updates
151
+
152
+
153
+ def save_photo_ids_file(photo_ids_file, photo_records):
154
+ """Save updated photo records back to the photo_ids file"""
155
+ with open(photo_ids_file, 'w', encoding='utf-8') as f:
156
+ for record in photo_records:
157
+ photo_id = record['photo_id']
158
+ hash_value = record['hash']
159
+ status = record['status']
160
+
161
+ # Always write status if it exists
162
+ if status:
163
+ f.write(f"{photo_id}\t{hash_value}\t{status}\n")
164
+ else:
165
+ f.write(f"{photo_id}\t{hash_value}\n")
166
+
167
+
168
+ def download_photos_for_uid(uid, photo_ids_file, photos_base_dir, max_workers):
169
+ """Download all photos for a single user ID"""
170
+ tasks, photo_records, has_updates = process_photo_ids_file(photo_ids_file, photos_base_dir, uid)
171
+
172
+ # Create a mapping from photo_id to record for easy updates
173
+ photo_id_to_record = {record['photo_id']: record for record in photo_records}
174
+
175
+ # Count initial statistics
176
+ valid_count = sum(1 for r in photo_records if r['status'] == "valid")
177
+ skipped_count = sum(1 for r in photo_records if r['status'] and r['status'] != "error")
178
+
179
+ if not tasks:
180
+ print(f"{uid}: No photos to download ({skipped_count} already processed, {valid_count} valid)")
181
+ # Save the file if statuses were updated
182
+ if has_updates:
183
+ save_photo_ids_file(photo_ids_file, photo_records)
184
+ return
185
+
186
+ print(f"Processing {uid}: {len(tasks)} photos to download ({skipped_count} skipped, {valid_count} valid)")
187
+
188
+ success_count = 0
189
+ error_count = 0
190
+
191
+ with ThreadPoolExecutor(max_workers=max_workers) as executor:
192
+ futures = {
193
+ executor.submit(download_photo, photo_id, hash_value, output_path, uid): (photo_id, hash_value)
194
+ for photo_id, hash_value, output_path in tasks
195
+ }
196
+
197
+ for future in tqdm(as_completed(futures), total=len(futures), desc=f"Downloading {uid}"):
198
+ photo_id, hash_value = futures[future]
199
+ try:
200
+ result_photo_id, status, error = future.result()
201
+
202
+ # Update the record with the download status
203
+ if result_photo_id in photo_id_to_record:
204
+ photo_id_to_record[result_photo_id]['status'] = status
205
+ has_updates = True
206
+
207
+ if status == "success":
208
+ success_count += 1
209
+ elif status == "error":
210
+ error_count += 1
211
+ if error:
212
+ print(f"\nError downloading {result_photo_id}: {error}")
213
+
214
+ # Sleep for 2 seconds every 50 requests
215
+ if (success_count + error_count) % 50 == 0:
216
+ time.sleep(2)
217
+
218
+ except Exception as e:
219
+ error_count += 1
220
+ print(f"\nException for {photo_id}: {e}")
221
+
222
+ # Save updated photo_ids file with download statuses only if there were updates
223
+ if has_updates:
224
+ save_photo_ids_file(photo_ids_file, photo_records)
225
+
226
+ print(f"Completed {uid}: {success_count} downloaded, {error_count} errors, {skipped_count} skipped, {valid_count} valid")
227
+
228
+
229
+ def clear_statuses(photo_ids_file):
230
+ """Clear all statuses from photo_ids file and save"""
231
+ photo_records = []
232
+
233
+ # Read all photo records
234
+ with open(photo_ids_file, 'r', encoding='utf-8') as f:
235
+ for line in f:
236
+ line = line.strip()
237
+
238
+ parts = line.split('\t')
239
+
240
+ photo_id = parts[0].strip()
241
+ hash_value = parts[1].strip()
242
+
243
+ # Clear status (set to None)
244
+ photo_records.append({
245
+ 'photo_id': photo_id,
246
+ 'hash': hash_value,
247
+ 'status': None
248
+ })
249
+
250
+ # Save with cleared statuses
251
+ save_photo_ids_file(photo_ids_file, photo_records)
252
+ return
253
+
254
+
255
+ def main():
256
+ parser = argparse.ArgumentParser(description="Fetch photos of selected users from YFCC")
257
+ parser.add_argument(
258
+ "--photo-ids-path",
259
+ type=str,
260
+ default="photo_ids",
261
+ help="Path to the DISBench dataset"
262
+ )
263
+ parser.add_argument(
264
+ "--images-path",
265
+ type=str,
266
+ default="images",
267
+ help="Path to the images directory"
268
+ )
269
+ parser.add_argument(
270
+ "--max-workers",
271
+ type=int,
272
+ default=16,
273
+ help="Maximum number of worker threads for downloading"
274
+ )
275
+ parser.add_argument(
276
+ "--clear",
277
+ action="store_true",
278
+ help="Clear the downloaded status and exit"
279
+ )
280
+
281
+ args = parser.parse_args()
282
+
283
+ photo_ids_path = Path(args.photo_ids_path)
284
+ images_path = Path(args.images_path)
285
+ max_workers = args.max_workers
286
+
287
+ # Get all photo_ids files
288
+ photo_ids_files = sorted([f for f in photo_ids_path.glob("*.txt")])
289
+
290
+ if not photo_ids_files:
291
+ print(f"No photo_ids files found in {photo_ids_path}")
292
+ return
293
+
294
+ # If clear is set, clear statuses and exit
295
+ if args.clear:
296
+ print(f"Clearing statuses for {len(photo_ids_files)} photo_ids files...")
297
+ for photo_ids_file in photo_ids_files:
298
+ uid = photo_ids_file.stem
299
+ print(f"Clearing statuses for {uid}...")
300
+ clear_statuses(photo_ids_file)
301
+ print("All statuses cleared!")
302
+ return
303
+
304
+ print(f"Found {len(photo_ids_files)} photo_ids files to process")
305
+
306
+ # Process each user's photo_ids file
307
+ for photo_ids_file in photo_ids_files:
308
+ uid = photo_ids_file.stem # Get filename without extension
309
+ download_photos_for_uid(uid, photo_ids_file, images_path, max_workers)
310
+
311
+ print("All downloads completed!")
312
+ return
313
+
314
+
315
+ if __name__ == '__main__':
316
+ main()
metadata/10287726@N02.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/10297518@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/10299779@N03.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/12276997@N06.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/12734746@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/13101981@N03.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/14580956@N08.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/14737255@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/14798958@N08.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/15352839@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/15803691@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/18383978@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/21435131@N06.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/21895046@N08.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/22017657@N05.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/22526649@N03.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/22736462@N07.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/23090753@N06.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/23518714@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/23736466@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/24232779@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/24413182@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/24468935@N03.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/24736216@N07.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/24819841@N06.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/25367139@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/25652622@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/25899413@N04.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/27550543@N02.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/27634886@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/27637456@N06.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/28157992@N03.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/28495173@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/30872191@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/31058815@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/35032604@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/39979407@N05.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/40817698@N07.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/41610421@N05.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/41838028@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/43145783@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/47554402@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/47642109@N04.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/49475364@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/49645113@N07.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/54368512@N00.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
metadata/55772206@N03.jsonl ADDED
The diff for this file is too large to render. See raw diff