ansabgillani Llabres commited on
Commit
049ad03
·
verified ·
0 Parent(s):

Duplicate from VLR-CVC/ComicsPAP

Browse files

Co-authored-by: Artemis Llabrés <[email protected]>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +59 -0
  2. README.md +547 -0
  3. caption_relevance/test-00000-of-00004.parquet +3 -0
  4. caption_relevance/test-00001-of-00004.parquet +3 -0
  5. caption_relevance/test-00002-of-00004.parquet +3 -0
  6. caption_relevance/test-00003-of-00004.parquet +3 -0
  7. caption_relevance/train-00000-of-00105.parquet +3 -0
  8. caption_relevance/train-00001-of-00105.parquet +3 -0
  9. caption_relevance/train-00002-of-00105.parquet +3 -0
  10. caption_relevance/train-00003-of-00105.parquet +3 -0
  11. caption_relevance/train-00004-of-00105.parquet +3 -0
  12. caption_relevance/train-00005-of-00105.parquet +3 -0
  13. caption_relevance/train-00006-of-00105.parquet +3 -0
  14. caption_relevance/train-00007-of-00105.parquet +3 -0
  15. caption_relevance/train-00008-of-00105.parquet +3 -0
  16. caption_relevance/train-00009-of-00105.parquet +3 -0
  17. caption_relevance/train-00010-of-00105.parquet +3 -0
  18. caption_relevance/train-00011-of-00105.parquet +3 -0
  19. caption_relevance/train-00012-of-00105.parquet +3 -0
  20. caption_relevance/train-00013-of-00105.parquet +3 -0
  21. caption_relevance/train-00014-of-00105.parquet +3 -0
  22. caption_relevance/train-00015-of-00105.parquet +3 -0
  23. caption_relevance/train-00016-of-00105.parquet +3 -0
  24. caption_relevance/train-00017-of-00105.parquet +3 -0
  25. caption_relevance/train-00018-of-00105.parquet +3 -0
  26. caption_relevance/train-00019-of-00105.parquet +3 -0
  27. caption_relevance/train-00020-of-00105.parquet +3 -0
  28. caption_relevance/train-00021-of-00105.parquet +3 -0
  29. caption_relevance/train-00022-of-00105.parquet +3 -0
  30. caption_relevance/train-00023-of-00105.parquet +3 -0
  31. caption_relevance/train-00024-of-00105.parquet +3 -0
  32. caption_relevance/train-00025-of-00105.parquet +3 -0
  33. caption_relevance/train-00026-of-00105.parquet +3 -0
  34. caption_relevance/train-00027-of-00105.parquet +3 -0
  35. caption_relevance/train-00028-of-00105.parquet +3 -0
  36. caption_relevance/train-00029-of-00105.parquet +3 -0
  37. caption_relevance/train-00030-of-00105.parquet +3 -0
  38. caption_relevance/train-00031-of-00105.parquet +3 -0
  39. caption_relevance/train-00032-of-00105.parquet +3 -0
  40. caption_relevance/train-00033-of-00105.parquet +3 -0
  41. caption_relevance/train-00034-of-00105.parquet +3 -0
  42. caption_relevance/train-00035-of-00105.parquet +3 -0
  43. caption_relevance/train-00036-of-00105.parquet +3 -0
  44. caption_relevance/train-00037-of-00105.parquet +3 -0
  45. caption_relevance/train-00038-of-00105.parquet +3 -0
  46. caption_relevance/train-00039-of-00105.parquet +3 -0
  47. caption_relevance/train-00040-of-00105.parquet +3 -0
  48. caption_relevance/train-00041-of-00105.parquet +3 -0
  49. caption_relevance/train-00042-of-00105.parquet +3 -0
  50. caption_relevance/train-00043-of-00105.parquet +3 -0
.gitattributes ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mds filter=lfs diff=lfs merge=lfs -text
13
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
14
+ *.model filter=lfs diff=lfs merge=lfs -text
15
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
16
+ *.npy filter=lfs diff=lfs merge=lfs -text
17
+ *.npz filter=lfs diff=lfs merge=lfs -text
18
+ *.onnx filter=lfs diff=lfs merge=lfs -text
19
+ *.ot filter=lfs diff=lfs merge=lfs -text
20
+ *.parquet filter=lfs diff=lfs merge=lfs -text
21
+ *.pb filter=lfs diff=lfs merge=lfs -text
22
+ *.pickle filter=lfs diff=lfs merge=lfs -text
23
+ *.pkl filter=lfs diff=lfs merge=lfs -text
24
+ *.pt filter=lfs diff=lfs merge=lfs -text
25
+ *.pth filter=lfs diff=lfs merge=lfs -text
26
+ *.rar filter=lfs diff=lfs merge=lfs -text
27
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
28
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
29
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
30
+ *.tar filter=lfs diff=lfs merge=lfs -text
31
+ *.tflite filter=lfs diff=lfs merge=lfs -text
32
+ *.tgz filter=lfs diff=lfs merge=lfs -text
33
+ *.wasm filter=lfs diff=lfs merge=lfs -text
34
+ *.xz filter=lfs diff=lfs merge=lfs -text
35
+ *.zip filter=lfs diff=lfs merge=lfs -text
36
+ *.zst filter=lfs diff=lfs merge=lfs -text
37
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
38
+ # Audio files - uncompressed
39
+ *.pcm filter=lfs diff=lfs merge=lfs -text
40
+ *.sam filter=lfs diff=lfs merge=lfs -text
41
+ *.raw filter=lfs diff=lfs merge=lfs -text
42
+ # Audio files - compressed
43
+ *.aac filter=lfs diff=lfs merge=lfs -text
44
+ *.flac filter=lfs diff=lfs merge=lfs -text
45
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
46
+ *.ogg filter=lfs diff=lfs merge=lfs -text
47
+ *.wav filter=lfs diff=lfs merge=lfs -text
48
+ # Image files - uncompressed
49
+ *.bmp filter=lfs diff=lfs merge=lfs -text
50
+ *.gif filter=lfs diff=lfs merge=lfs -text
51
+ *.png filter=lfs diff=lfs merge=lfs -text
52
+ *.tiff filter=lfs diff=lfs merge=lfs -text
53
+ # Image files - compressed
54
+ *.jpg filter=lfs diff=lfs merge=lfs -text
55
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
56
+ *.webp filter=lfs diff=lfs merge=lfs -text
57
+ # Video files - compressed
58
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
59
+ *.webm filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,547 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ pretty_name: 'Comics: Pick-A-Panel'
5
+ tags:
6
+ - comics
7
+ dataset_info:
8
+ - config_name: caption_relevance
9
+ features:
10
+ - name: sample_id
11
+ dtype: string
12
+ - name: context
13
+ sequence: image
14
+ - name: options
15
+ sequence: image
16
+ - name: index
17
+ dtype: int32
18
+ - name: solution_index
19
+ dtype: int32
20
+ - name: split
21
+ dtype: string
22
+ - name: task_type
23
+ dtype: string
24
+ - name: previous_panel_caption
25
+ dtype: string
26
+ splits:
27
+ - name: val
28
+ num_bytes: 530485241.0
29
+ num_examples: 262
30
+ - name: test
31
+ num_bytes: 1670410617.0
32
+ num_examples: 932
33
+ - name: train
34
+ num_bytes: 52102789433.0
35
+ num_examples: 23604
36
+ download_size: 19052013978
37
+ dataset_size: 54303685291.0
38
+ - config_name: char_coherence
39
+ features:
40
+ - name: sample_id
41
+ dtype: string
42
+ - name: context
43
+ sequence: image
44
+ - name: options
45
+ sequence: image
46
+ - name: index
47
+ dtype: int32
48
+ - name: solution_index
49
+ dtype: int32
50
+ - name: split
51
+ dtype: string
52
+ - name: task_type
53
+ dtype: string
54
+ - name: previous_panel_caption
55
+ dtype: string
56
+ splits:
57
+ - name: train
58
+ num_bytes: 27257333324.718
59
+ num_examples: 10157
60
+ - name: val
61
+ num_bytes: 379249617.0
62
+ num_examples: 143
63
+ - name: test
64
+ num_bytes: 1139813763.0
65
+ num_examples: 489
66
+ download_size: 23700133102
67
+ dataset_size: 28776396704.718
68
+ - config_name: sequence_filling
69
+ features:
70
+ - name: sample_id
71
+ dtype: string
72
+ - name: context
73
+ sequence: image
74
+ - name: options
75
+ sequence: image
76
+ - name: index
77
+ dtype: int32
78
+ - name: solution_index
79
+ dtype: int32
80
+ - name: split
81
+ dtype: string
82
+ - name: task_type
83
+ dtype: string
84
+ - name: previous_panel_caption
85
+ dtype: string
86
+ splits:
87
+ - name: val
88
+ num_bytes: 1230082746
89
+ num_examples: 262
90
+ - name: test
91
+ num_bytes: 3889446893
92
+ num_examples: 932
93
+ - name: train
94
+ num_bytes: 119656345637.788
95
+ num_examples: 23604
96
+ download_size: 36861355207
97
+ dataset_size: 124775875276.788
98
+ - config_name: text_closure
99
+ features:
100
+ - name: sample_id
101
+ dtype: string
102
+ - name: context
103
+ sequence: image
104
+ - name: options
105
+ sequence: image
106
+ - name: index
107
+ dtype: int32
108
+ - name: solution_index
109
+ dtype: int32
110
+ - name: split
111
+ dtype: string
112
+ - name: task_type
113
+ dtype: string
114
+ - name: previous_panel_caption
115
+ dtype: string
116
+ splits:
117
+ - name: test
118
+ num_bytes: 2839781239
119
+ num_examples: 924
120
+ - name: val
121
+ num_bytes: 886890050
122
+ num_examples: 259
123
+ - name: train
124
+ num_bytes: 67723135724.352
125
+ num_examples: 17898
126
+ download_size: 55595829405
127
+ dataset_size: 71449807013.35199
128
+ - config_name: visual_closure
129
+ features:
130
+ - name: sample_id
131
+ dtype: string
132
+ - name: context
133
+ sequence: image
134
+ - name: options
135
+ sequence: image
136
+ - name: index
137
+ dtype: int32
138
+ - name: solution_index
139
+ dtype: int32
140
+ - name: split
141
+ dtype: string
142
+ - name: task_type
143
+ dtype: string
144
+ - name: previous_panel_caption
145
+ dtype: string
146
+ splits:
147
+ - name: val
148
+ num_bytes: 1356539432
149
+ num_examples: 300
150
+ - name: test
151
+ num_bytes: 4020998551
152
+ num_examples: 1000
153
+ - name: train
154
+ num_bytes: 116639548171.824
155
+ num_examples: 24166
156
+ download_size: 39958402068
157
+ dataset_size: 122017086154.824
158
+ configs:
159
+ - config_name: caption_relevance
160
+ data_files:
161
+ - split: val
162
+ path: caption_relevance/val-*
163
+ - split: test
164
+ path: caption_relevance/test-*
165
+ - split: train
166
+ path: caption_relevance/train-*
167
+ - config_name: char_coherence
168
+ data_files:
169
+ - split: val
170
+ path: char_coherence/val-*
171
+ - split: test
172
+ path: char_coherence/test-*
173
+ - split: train
174
+ path: char_coherence/train-*
175
+ - config_name: sequence_filling
176
+ data_files:
177
+ - split: val
178
+ path: sequence_filling/val-*
179
+ - split: test
180
+ path: sequence_filling/test-*
181
+ - split: train
182
+ path: sequence_filling/train-*
183
+ - config_name: text_closure
184
+ data_files:
185
+ - split: val
186
+ path: text_closure/val-*
187
+ - split: test
188
+ path: text_closure/test-*
189
+ - split: train
190
+ path: text_closure/train-*
191
+ - config_name: visual_closure
192
+ data_files:
193
+ - split: val
194
+ path: visual_closure/val-*
195
+ - split: test
196
+ path: visual_closure/test-*
197
+ - split: train
198
+ path: visual_closure/train-*
199
+ license: cc-by-sa-4.0
200
+ ---
201
+
202
+ # Comics: Pick-A-Panel
203
+
204
+ _Updated val and test on 25/02/2025_
205
+
206
+ This is the dataset for the [ICDAR 2025 Competition on Comics Understanding in the Era of Foundational Models](https://rrc.cvc.uab.es/?ch=31&com=introduction).
207
+ Please, check out our [🚀 arxiv paper 🚀](https://arxiv.org/abs/2503.08561) for more information 😊
208
+ The competition is hosted in the [Robust Reading Competition website](https://rrc.cvc.uab.es/?ch=31&com=introduction) and the leaderboard is available [here](https://rrc.cvc.uab.es/?ch=31&com=evaluation).
209
+
210
+ The dataset contains five subtask or skills:
211
+
212
+ <details>
213
+
214
+ <summary>Sequence Filling</summary>
215
+
216
+ ![Sequence Filling](figures/seq_filling.png)
217
+
218
+ Given a sequence of comic panels, a missing panel, and a set of option panels, the task is to pick the panel that best fits the sequence.
219
+ </details>
220
+
221
+ <details>
222
+
223
+ <summary>Character Coherence, Visual Closure, Text Closure</summary>
224
+
225
+ ![Character Coherence](figures/closure.png)
226
+
227
+ These skills require understanding the context sequence to then pick the best panel to continue the story, focusing on the characters, the visual elements, and the text:
228
+ - Character Coherence: Given a sequence of comic panels, pick the panel from the two options that best continues the story in a coherent with the characters. Both options are the same panel, but the text in the speech bubbles has been swapped.
229
+ - Visual Closure: Given a sequence of comic panels, pick the panel from the options that best continues the story in a coherent way with the visual elements.
230
+ - Text Closure: Given a sequence of comic panels, pick the panel from the options that best continues the story in a coherent way with the text. All options are the same panel, but with text in the speech retrieved from different panels.
231
+
232
+ </details>
233
+
234
+ <details>
235
+
236
+ <summary>Caption Relevance</summary>
237
+
238
+ ![Caption Relevance](figures/caption_relevance.png)
239
+
240
+ Given a caption from the previous panel, select the panel that best continues the story.
241
+ </details>
242
+
243
+ ## Loading the Data
244
+
245
+ ```python
246
+ from datasets import load_dataset
247
+
248
+ skill = "sequence_filling" # "sequence_filling", "char_coherence", "visual_closure", "text_closure", "caption_relevance"
249
+ split = "val" # "val", "test", "train"
250
+ dataset = load_dataset("VLR-CVC/ComicsPAP", skill, split=split)
251
+ ```
252
+
253
+ <details>
254
+
255
+ <summary>Map to single images</summary>
256
+
257
+ If your model can only process single images, you can render each sample as a single image:
258
+
259
+ ![Single Image Example](figures/single_image_seq_filling_example.png)
260
+
261
+
262
+ ```python
263
+ from PIL import Image, ImageDraw, ImageFont
264
+ import numpy as np
265
+ from datasets import Features, Value, Image as ImageFeature
266
+
267
+ class SingleImagePickAPanel:
268
+ def __init__(self, max_size=500, margin=10, label_space=20, font_path=None):
269
+ if font_path is None:
270
+ raise ValueError("Font path must be provided. Testing was done with 'Arial.ttf'")
271
+ self.max_size = max_size
272
+ self.margin = margin
273
+ self.label_space = label_space
274
+ # Add separate font sizes
275
+ self.label_font_size = 20
276
+ self.number_font_size = 24
277
+
278
+ self.font_path = font_path
279
+
280
+ def resize_image(self, img):
281
+ """Resize image keeping aspect ratio if longest edge > max_size"""
282
+ if max(img.size) > self.max_size:
283
+ ratio = self.max_size / max(img.size)
284
+ new_size = tuple(int(dim * ratio) for dim in img.size)
285
+ return img.resize(new_size, Image.Resampling.LANCZOS)
286
+ return img
287
+
288
+ def create_mask_panel(self, width, height):
289
+ """Create a question mark panel"""
290
+ mask_panel = Image.new("RGB", (width, height), (200, 200, 200))
291
+ draw = ImageDraw.Draw(mask_panel)
292
+ font_size = int(height * 0.8)
293
+ try:
294
+ font = ImageFont.truetype(self.font_path, font_size)
295
+ except:
296
+ raise ValueError("Font file not found")
297
+
298
+ text = "?"
299
+ bbox = draw.textbbox((0, 0), text, font=font)
300
+ text_x = (width - (bbox[2] - bbox[0])) // 2
301
+ text_y = (height - (bbox[3] - bbox[1])) // 2
302
+ draw.text((text_x, text_y), text, fill="black", font=font)
303
+ return mask_panel
304
+
305
+ def draw_number_on_panel(self, panel, number, font):
306
+ """Draw number on the bottom of the panel with background"""
307
+ draw = ImageDraw.Draw(panel)
308
+
309
+ # Get text size
310
+ bbox = draw.textbbox((0, 0), str(number), font=font)
311
+ text_width = bbox[2] - bbox[0]
312
+ text_height = bbox[3] - bbox[1]
313
+
314
+ # Calculate position (bottom-right corner)
315
+ padding = 2
316
+ text_x = panel.size[0] - text_width - padding
317
+ text_y = panel.size[1] - text_height - padding
318
+
319
+ # Draw semi-transparent background
320
+ bg_rect = [(text_x - padding, text_y - padding),
321
+ (text_x + text_width + padding, text_y + text_height + padding)]
322
+ draw.rectangle(bg_rect, fill=(255, 255, 255, 180))
323
+
324
+ # Draw text
325
+ draw.text((text_x, text_y), str(number), fill="black", font=font)
326
+ return panel
327
+
328
+ def map_to_single_image(self, examples):
329
+ """Process a batch of examples from a HuggingFace dataset"""
330
+ single_images = []
331
+
332
+ for i in range(len(examples['sample_id'])):
333
+ # Get context and options for current example
334
+ context = examples['context'][i] if len(examples['context'][i]) > 0 else []
335
+ options = examples['options'][i]
336
+
337
+ # Resize all images
338
+ context = [self.resize_image(img) for img in context]
339
+ options = [self.resize_image(img) for img in options]
340
+
341
+ # Calculate common panel size (use median size to avoid outliers)
342
+ all_panels = context + options
343
+ if len(all_panels) > 0:
344
+ widths = [img.size[0] for img in all_panels]
345
+ heights = [img.size[1] for img in all_panels]
346
+ panel_width = int(np.median(widths))
347
+ panel_height = int(np.median(heights))
348
+
349
+ # Resize all panels to common size
350
+ context = [img.resize((panel_width, panel_height)) for img in context]
351
+ options = [img.resize((panel_width, panel_height)) for img in options]
352
+
353
+ # Create mask panel for sequence filling tasks if needed
354
+ if 'index' in examples and len(context) > 0:
355
+ mask_idx = examples['index'][i]
356
+ mask_panel = self.create_mask_panel(panel_width, panel_height)
357
+ context.insert(mask_idx, mask_panel)
358
+
359
+ # Calculate canvas dimensions based on whether we have context
360
+ if len(context) > 0:
361
+ context_row_width = panel_width * len(context) + self.margin * (len(context) - 1)
362
+ options_row_width = panel_width * len(options) + self.margin * (len(options) - 1)
363
+ canvas_width = max(context_row_width, options_row_width)
364
+ canvas_height = (panel_height * 2 +
365
+ self.label_space * 2)
366
+ else:
367
+ # Only options row for caption_relevance
368
+ canvas_width = panel_width * len(options) + self.margin * (len(options) - 1)
369
+ canvas_height = (panel_height +
370
+ self.label_space)
371
+
372
+ # Create canvas
373
+ final_image = Image.new("RGB", (canvas_width, canvas_height), "white")
374
+ draw = ImageDraw.Draw(final_image)
375
+
376
+ try:
377
+ label_font = ImageFont.truetype(self.font_path, self.label_font_size)
378
+ number_font = ImageFont.truetype(self.font_path, self.number_font_size)
379
+ except:
380
+ raise ValueError("Font file not found")
381
+
382
+ current_y = 0
383
+
384
+ # Add context section if it exists
385
+ if len(context) > 0:
386
+ # Draw "Context" label
387
+ bbox = draw.textbbox((0, 0), "Context", font=label_font)
388
+ text_x = (canvas_width - (bbox[2] - bbox[0])) // 2
389
+ draw.text((text_x, current_y), "Context", fill="black", font=label_font)
390
+ current_y += self.label_space
391
+
392
+ # Paste context panels
393
+ x_offset = (canvas_width - (panel_width * len(context) +
394
+ self.margin * (len(context) - 1))) // 2
395
+ for panel in context:
396
+ final_image.paste(panel, (x_offset, current_y))
397
+ x_offset += panel_width + self.margin
398
+ current_y += panel_height
399
+
400
+ # Add "Options" label
401
+ bbox = draw.textbbox((0, 0), "Options", font=label_font)
402
+ text_x = (canvas_width - (bbox[2] - bbox[0])) // 2
403
+ draw.text((text_x, current_y), "Options", fill="black", font=label_font)
404
+ current_y += self.label_space
405
+
406
+ # Paste options with numbers on panels
407
+ x_offset = (canvas_width - (panel_width * len(options) +
408
+ self.margin * (len(options) - 1))) // 2
409
+ for idx, panel in enumerate(options):
410
+ # Create a copy of the panel to draw on
411
+ panel_with_number = panel.copy()
412
+ if panel_with_number.mode != 'RGBA':
413
+ panel_with_number = panel_with_number.convert('RGBA')
414
+
415
+ # Draw number on panel
416
+ panel_with_number = self.draw_number_on_panel(
417
+ panel_with_number,
418
+ idx,
419
+ number_font
420
+ )
421
+
422
+ # Paste the panel with number
423
+ final_image.paste(panel_with_number, (x_offset, current_y), panel_with_number)
424
+ x_offset += panel_width + self.margin
425
+
426
+ # Convert final_image to PIL Image format (instead of numpy array)
427
+ single_images.append(final_image)
428
+
429
+ # Prepare batch output
430
+ examples['single_image'] = single_images
431
+
432
+ return examples
433
+
434
+ from datasets import load_dataset
435
+
436
+ skill = "sequence_filling" # "sequence_filling", "char_coherence", "visual_closure", "text_closure", "caption_relevance"
437
+ split = "val" # "val", "test"
438
+ dataset = load_dataset("VLR-CVC/ComicsPAP", skill, split=split)
439
+
440
+ processor = SingleImagePickAPanel()
441
+ dataset = dataset.map(
442
+ processor.map_to_single_image,
443
+ batched=True,
444
+ batch_size=32,
445
+ remove_columns=['context', 'options']
446
+ )
447
+ dataset.save_to_disk(f"ComicsPAP_{skill}_{split}_single_images")
448
+ ```
449
+
450
+ </details>
451
+
452
+ ## Evaluation
453
+
454
+ The evaluation metric for all tasks is the accuracy of the model's predictions. The overall accuracy is calculated as the weighted average of the accuracy of each subtask, with the weights being the number of examples in each subtask.
455
+
456
+ To evaluate on the test set you must submit your predictions to the [Robust Reading Competition website](https://rrc.cvc.uab.es/?ch=31&com=introduction), as a json file with the following structure:
457
+
458
+ ```json
459
+ [
460
+ { "sample_id" : "sample_id_0", "correct_panel_id" : 3},
461
+ { "sample_id" : "sample_id_1", "correct_panel_id" : 1},
462
+ { "sample_id" : "sample_id_2", "correct_panel_id" : 4},
463
+ ...,
464
+ ]
465
+ ```
466
+
467
+ Where `sample_id` is the id of the sample, `correct_panel_id` is the prediction of your model as the index of the correct panel in the options.
468
+
469
+ <details>
470
+
471
+ <summary>Pseudocode for the evaluation on val set, adapt for your model:</summary>
472
+
473
+ ```python
474
+ skills = {
475
+ "sequence_filling": {
476
+ "num_examples": 262
477
+ },
478
+ "char_coherence": {
479
+ "num_examples": 143
480
+ },
481
+ "visual_closure": {
482
+ "num_examples": 300
483
+ },
484
+ "text_closure": {
485
+ "num_examples": 259
486
+ },
487
+ "caption_relevance": {
488
+ "num_examples": 262
489
+ }
490
+ }
491
+
492
+ for skill in skills:
493
+ dataset = load_dataset("VLR-CVC/ComicsPAP", skill, split="val")
494
+ correct = 0
495
+ total = 0
496
+ for example in dataset:
497
+ # Your model prediction
498
+ prediction = model.generate(**example)
499
+ prediction = post_process(prediction)
500
+ if prediction == example["solution_index"]:
501
+ correct += 1
502
+ total += 1
503
+ accuracy = correct / total
504
+ print(f"Accuracy for {skill}: {accuracy}")
505
+
506
+ assert total == skills[skill]["num_examples"]
507
+ skills[skill]["accuracy"] = accuracy
508
+
509
+ # Calculate overall accuracy
510
+ total_examples = sum(skill["num_examples"] for skill in skills.values())
511
+ overall_accuracy = sum(skill["num_examples"] * skill["accuracy"] for skill in skills.values()) / total_examples
512
+ print(f"Overall accuracy: {overall_accuracy}")
513
+
514
+ ```
515
+
516
+ </details>
517
+
518
+ ## Baselines
519
+
520
+ Find code for evaluation and training at: [https://github.com/llabres/ComicsPAP](https://github.com/llabres/ComicsPAP)
521
+
522
+ Baselines on the validation set using single images:
523
+
524
+ | Model | Repo | Sequence Filling (%) | Character Coherence (%) | Visual Closure (%) | Text Closure (%) | Caption Relevance (%) | Total (%) |
525
+ | :------------------------: | :---------------------------------------------------------------------------------: | :------------------: | :---------------------: | :----------------: | :--------------: | :-------------------: | :-------: |
526
+ | Random | | 20.22 | 50.00 | 14.41 | 25.00 | 25.00 | 24.30 |
527
+ | Qwen2.5-VL-3B (Zero-Shot) | [Qwen/Qwen2.5-VL-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-3B-Instruct) | 27.48 | 48.95 | 21.33 | 27.41 | 32.82 | 29.61 |
528
+ | Qwen2.5-VL-7B (Zero-Shot) | [Qwen/Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct) | 30.53 | 54.55 | 22.00 | 37.45 | 40.84 | 34.91 |
529
+ | Qwen2.5-VL-72B (Zero-Shot) | [Qwen/Qwen2.5-VL-72B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-72B-Instruct) | 46.88 | 53.84 | 23.66 | 55.60 | 38.17 | 41.27 |
530
+ | Qwen2.5-VL-3B (Lora Fine-Tuned) | [VLR-CVC/Qwen2.5-VL-3B-Instruct-lora-ComicsPAP](https://huggingface.co/VLR-CVC/Qwen2.5-VL-3B-Instruct-lora-ComicsPAP) | 62.21 | **93.01** | **42.33** | 63.71 | 35.49 | 55.55 |
531
+ | Qwen2.5-VL-7B (Lora Fine-Tuned) | [VLR-CVC/Qwen2.5-VL-7B-Instruct-lora-ComicsPAP](https://huggingface.co/VLR-CVC/Qwen2.5-VL-7B-Instruct-lora-ComicsPAP) | **69.08** | **93.01** | 42.00 | **74.90** | **49.62** | **62.31** |
532
+
533
+ ## Citation
534
+ If you use the dataset, please cite our work :
535
+ ```bibtex
536
+ @InProceedings{vivoli2025comicspap,
537
+ author="Vivoli, Emanuele and Llabr{\'e}s, Artemis and Souibgui, Mohamed Ali and Bertini, Marco and Llobet, Ernest Valveny and Karatzas, Dimosthenis",
538
+ editor="Yin, Xu-Cheng and Karatzas, Dimosthenis and Lopresti, Daniel",
539
+ title="ComicsPAP: Understanding Comic Strips by Picking the Correct Panel",
540
+ booktitle="Document Analysis and Recognition -- ICDAR 2025",
541
+ year="2026",
542
+ publisher="Springer Nature Switzerland",
543
+ address="Cham",
544
+ pages="337--350",
545
+ isbn="978-3-032-04614-7"
546
+ }
547
+ ```
caption_relevance/test-00000-of-00004.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14c45bf8b57e5bb1c8f495f69b89f2ad5065d1a918c2544aa70aa406848c0592
3
+ size 426890006
caption_relevance/test-00001-of-00004.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f48086c67c56b62764f91c90ac846a60fb9fac9f1f10af7a587b89862ee2d2aa
3
+ size 415248306
caption_relevance/test-00002-of-00004.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05cf2f4d732fce335252042f2a9469260bb4f1b18fbc74655b675068fefa6e63
3
+ size 424462591
caption_relevance/test-00003-of-00004.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1dbe064947c25b0376d91cd393e4ef78f875b0c1a16b9e0f2818c36d65c7ff14
3
+ size 403268183
caption_relevance/train-00000-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b791a9eaf0555fcb33552989f14fe5f7fb4794ec5518388f32cb26dd5bb516c
3
+ size 228336594
caption_relevance/train-00001-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef14d375fce0533d10645b9bbb23ebb21933d80ad7ce5e9fdddd93462278f76d
3
+ size 230646730
caption_relevance/train-00002-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:523e9c8c7f5fafc26f1f69fe11f4fc1a1b4972116ad1f47b715ec68d8a8d73ba
3
+ size 156195984
caption_relevance/train-00003-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0fe415da448bf0f2553cdc825f849e5d3e7e23f200aecfe9449c141cc48fd478
3
+ size 119426323
caption_relevance/train-00004-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9cb1018d38ec4703231f2272da417226a129b2bea35f217586d91dcaf77f106a
3
+ size 146699108
caption_relevance/train-00005-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:afcd302d33a8edec832df777d294f29ee8b4ffa8ee16a891184befafdfb85354
3
+ size 187226495
caption_relevance/train-00006-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c610b18ce1e684cae5378a5635ecc6a5da64717f24db2afb58700c1e970d834e
3
+ size 255707230
caption_relevance/train-00007-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2693fa57825cba4bb4cc777771e314b4d243dc22616fbaf09184dfeb8fac4e9
3
+ size 245281357
caption_relevance/train-00008-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b6d2481eb265db8b5ab8c90921b7f96328607bc21ccf62d3b19569146ee5e1d
3
+ size 119534455
caption_relevance/train-00009-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6beb40c2e702a2b4f7e19dd63858af3657c10726374f75af889e5521092fead0
3
+ size 146391204
caption_relevance/train-00010-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd9e365aeee9bdacb7e394fc1bcecb9b93a0c7a630011eb82bc84e4dc1ca2be4
3
+ size 267628162
caption_relevance/train-00011-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52c5ac42b021dbc0b47c17f527abe6c0a4df7baa9f24a0eb92b3ba71eb701dd5
3
+ size 168298268
caption_relevance/train-00012-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6f4de78a4ca2c8027fa7f3432918f6d1a675c7aa4113761b483f104c5279b396
3
+ size 125293819
caption_relevance/train-00013-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fd0101df0c38ec97659be4a8f729f9cb01645f468f0a4c8e214cd1a909665b40
3
+ size 109618195
caption_relevance/train-00014-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3382dcd4b956eead224aa686dd0a90c05fb5b6422384067ee677f7c33cd3148
3
+ size 132853681
caption_relevance/train-00015-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34f5485c80ac96421828041fc88e04461837d7b1e9b71e4f3568616015fdcded
3
+ size 164334840
caption_relevance/train-00016-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73ccb9069d22ca33008dd9a7a0143dbeac90d97e018b864e31fe8d993826e1f8
3
+ size 141995189
caption_relevance/train-00017-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ed6e2f0c01ee4fe55cf4b9e8150e6835ac3fad7f4cb59b9a5f0302d2b7446bb
3
+ size 149952140
caption_relevance/train-00018-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec1838fbe0c2774aa01990b25a32a8c7f0c78263941eb034a7f68bfb86b8c72d
3
+ size 199841467
caption_relevance/train-00019-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aff53a428a8b89060ef2ecb01d138e80ae8c567f332a5a2198de0d298abc1481
3
+ size 73575647
caption_relevance/train-00020-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:743598e781c8b7a8c7769274eb286922e6f2c6c8eacd9865ac77ec4d7f795da9
3
+ size 75939757
caption_relevance/train-00021-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de12e5f743fee01b185dc22114bfddc8aac8e6db8437a3c1ca588d3938d51d99
3
+ size 54199582
caption_relevance/train-00022-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a06cdffd292b0c28f5d598a677d41ebbf35f49535ca9973d475e412d7fa5681e
3
+ size 89533958
caption_relevance/train-00023-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da5512ee2fac942d7b108a31215f7f3c2f7b236f6d2df9a02bede866dbaecc3f
3
+ size 130381073
caption_relevance/train-00024-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73dd12b3fcb8a663cf025cea1a2a9e2643f90632f8dc69e0c47e094784181894
3
+ size 112622710
caption_relevance/train-00025-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42060525076fabc786ad7d5c14a1ad3d291d7f70c33c0a18b7249a42c67ef513
3
+ size 132539295
caption_relevance/train-00026-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4cb9115a574915d08c5f005abd024495a3eec02c97be1a92188ff0323dd787da
3
+ size 142212323
caption_relevance/train-00027-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89564af3d1fd57f3d14e26f19cd1c274512989c52217bf8f7754a1c068db45e0
3
+ size 104074724
caption_relevance/train-00028-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6eef77fa16d509859bcf6592c16cc5e118d5c345cf68609c4cba5437c2a1d8ec
3
+ size 124456104
caption_relevance/train-00029-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:503a8dc86a3c2a1d63fc49570d17c2de063fd472494468488145720f28661841
3
+ size 141842703
caption_relevance/train-00030-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ceb1021db2ca2e86b3fcb1e9a8c6c4fc0cff83f9e972254f5c9cad2bd0f4280e
3
+ size 135296993
caption_relevance/train-00031-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:61f4e9b1e3089cb4073707dfec1872221707cc55f5fbf2f3545a0c00b1f5929b
3
+ size 139458482
caption_relevance/train-00032-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e09d1481821a251cc38a909b125f9911353e44e6e5ab2a8fb299bf54f4b1db74
3
+ size 167706486
caption_relevance/train-00033-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29774ae9da858d581f54988d693ac86426df3f87de8a8080fd3e9877a40f2dc0
3
+ size 138371611
caption_relevance/train-00034-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85999158b2fbd6d7594f926571831faa1fe2351d435541c95c0f2c08493b95c8
3
+ size 134732291
caption_relevance/train-00035-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:664d3b148fab562028c7f49f9299d794d5c9215f98dbad22e6606be2b4dd4427
3
+ size 133264330
caption_relevance/train-00036-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3910676a7d5779e128b0f0ecd046401fc3b2c3ce12b76262fba7a7eda1346cc
3
+ size 134803117
caption_relevance/train-00037-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0c67d550318cd7e46c777b2cc13c136888c5f6e09b338289c96d0306855c1ab
3
+ size 173822880
caption_relevance/train-00038-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc1736f6cdb69a0839b288491b55f6bab6589dec614c130d9d6e433cef37b8c9
3
+ size 219928163
caption_relevance/train-00039-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcec799bb8f46e75d2ebf168bac745c1e5da55fc6afffdf5f91204bc4c0d603d
3
+ size 225702240
caption_relevance/train-00040-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77665183ee6b64d840c24370f9490dbd7eaa114ae0dccb8d1adeeacc1113e9b7
3
+ size 218598057
caption_relevance/train-00041-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c15db081a50c45982211a77898f281596c70c25da1a33050a2ac4ada67c8438b
3
+ size 171205418
caption_relevance/train-00042-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b195bd3d6790021756ebcfc2a77f88aa930d78d7f9ec85c3aabc3712b84fec8c
3
+ size 102949174
caption_relevance/train-00043-of-00105.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ff643af576b5478da6617456814c2c4c81aa04c3961abd97dbeb47e49f378e3
3
+ size 162042434