Datasets:

Modalities:
Image
Text
Formats:
parquet
Languages:
English
ArXiv:
Libraries:
Datasets
Dask
License:
File size: 19,638 Bytes
674c6f2
5c9419e
 
 
82e33f5
 
42da7f1
f32f964
d46900e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f7220c
 
 
dcea263
 
 
16c314a
 
 
 
 
f32f964
42da7f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f32f964
 
 
a2e9d09
 
 
fc59a8a
 
 
 
f32f964
85407e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7ddb05b
85407e3
b5ec9d8
7ddb05b
b5ec9d8
bff25b2
 
 
 
 
3a4f976
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fdd0b64
7ddb05b
fdd0b64
fde4a59
7ddb05b
fde4a59
3dfd75b
 
 
 
 
8e1d0f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8b517dd
7ddb05b
8b517dd
157cb17
7ddb05b
157cb17
5191cfa
 
 
 
 
42da7f1
ce6d313
 
 
 
 
 
16c314a
 
f32f964
 
 
 
 
 
 
 
85407e3
 
 
 
b5ec9d8
 
bff25b2
 
3a4f976
 
 
 
fdd0b64
 
3dfd75b
 
8e1d0f4
 
 
 
d691f89
 
5191cfa
 
7ddb05b
674c6f2
82e33f5
 
 
99a3b03
 
4c648a7
 
3eec0bf
 
82e33f5
 
1ec086b
e831b3a
8c6662d
e831b3a
 
 
037cce0
1ec086b
6ad3683
1ec086b
e831b3a
8c6662d
ab25a51
e831b3a
 
6ad3683
037cce0
6ad3683
 
ab25a51
1ec086b
6ad3683
1ec086b
e831b3a
8c6662d
e831b3a
 
 
6ad3683
1ec086b
6ad3683
 
1ec086b
 
 
 
9473143
b3f4a99
c56be29
1ec086b
 
 
8e04777
1ec086b
8e04777
1ec086b
 
8e04777
 
 
 
 
 
 
 
 
037cce0
 
 
8e04777
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c56be29
8e04777
 
 
 
 
 
 
 
c56be29
8e04777
6ad3683
1ec086b
 
3eec0bf
 
 
 
b7c73d3
3eec0bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c56be29
3eec0bf
 
 
 
8c6662d
3eec0bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8c6662d
 
6125a21
 
8455802
b3f4a99
 
 
 
 
 
15b9747
300c1e5
 
09cce3b
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
---
language:
- en
pretty_name: 'Comics: Pick-A-Panel'
tags:
- comics
dataset_info:
- config_name: caption_relevance
  features:
  - name: sample_id
    dtype: string
  - name: context
    sequence: image
  - name: options
    sequence: image
  - name: index
    dtype: int32
  - name: solution_index
    dtype: int32
  - name: split
    dtype: string
  - name: task_type
    dtype: string
  - name: previous_panel_caption
    dtype: string
  splits:
  - name: val
    num_bytes: 530485241.0
    num_examples: 262
  - name: test
    num_bytes: 1670410617.0
    num_examples: 932
  - name: train
    num_bytes: 52102789433.0
    num_examples: 23604
  download_size: 19052013978
  dataset_size: 54303685291.0
- config_name: char_coherence
  features:
  - name: sample_id
    dtype: string
  - name: context
    sequence: image
  - name: options
    sequence: image
  - name: index
    dtype: int32
  - name: solution_index
    dtype: int32
  - name: split
    dtype: string
  - name: task_type
    dtype: string
  - name: previous_panel_caption
    dtype: string
  splits:
  - name: train
    num_bytes: 27257333324.718
    num_examples: 10157
  - name: val
    num_bytes: 379249617.0
    num_examples: 143
  - name: test
    num_bytes: 1139813763.0
    num_examples: 489
  download_size: 23700133102
  dataset_size: 28776396704.718
- config_name: sequence_filling
  features:
  - name: sample_id
    dtype: string
  - name: context
    sequence: image
  - name: options
    sequence: image
  - name: index
    dtype: int32
  - name: solution_index
    dtype: int32
  - name: split
    dtype: string
  - name: task_type
    dtype: string
  - name: previous_panel_caption
    dtype: string
  splits:
  - name: val
    num_bytes: 1230082746
    num_examples: 262
  - name: test
    num_bytes: 3889446893
    num_examples: 932
  - name: train
    num_bytes: 119656345637.788
    num_examples: 23604
  download_size: 36861355207
  dataset_size: 124775875276.788
- config_name: text_closure
  features:
  - name: sample_id
    dtype: string
  - name: context
    sequence: image
  - name: options
    sequence: image
  - name: index
    dtype: int32
  - name: solution_index
    dtype: int32
  - name: split
    dtype: string
  - name: task_type
    dtype: string
  - name: previous_panel_caption
    dtype: string
  splits:
  - name: test
    num_bytes: 2839781239
    num_examples: 924
  - name: val
    num_bytes: 886890050
    num_examples: 259
  - name: train
    num_bytes: 67723135724.352
    num_examples: 17898
  download_size: 55595829405
  dataset_size: 71449807013.35199
- config_name: visual_closure
  features:
  - name: sample_id
    dtype: string
  - name: context
    sequence: image
  - name: options
    sequence: image
  - name: index
    dtype: int32
  - name: solution_index
    dtype: int32
  - name: split
    dtype: string
  - name: task_type
    dtype: string
  - name: previous_panel_caption
    dtype: string
  splits:
  - name: val
    num_bytes: 1356539432
    num_examples: 300
  - name: test
    num_bytes: 4020998551
    num_examples: 1000
  - name: train
    num_bytes: 116639548171.824
    num_examples: 24166
  download_size: 39958402068
  dataset_size: 122017086154.824
configs:
- config_name: caption_relevance
  data_files:
  - split: val
    path: caption_relevance/val-*
  - split: test
    path: caption_relevance/test-*
  - split: train
    path: caption_relevance/train-*
- config_name: char_coherence
  data_files:
  - split: val
    path: char_coherence/val-*
  - split: test
    path: char_coherence/test-*
  - split: train
    path: char_coherence/train-*
- config_name: sequence_filling
  data_files:
  - split: val
    path: sequence_filling/val-*
  - split: test
    path: sequence_filling/test-*
  - split: train
    path: sequence_filling/train-*
- config_name: text_closure
  data_files:
  - split: val
    path: text_closure/val-*
  - split: test
    path: text_closure/test-*
  - split: train
    path: text_closure/train-*
- config_name: visual_closure
  data_files:
  - split: val
    path: visual_closure/val-*
  - split: test
    path: visual_closure/test-*
  - split: train
    path: visual_closure/train-*
license: cc-by-sa-4.0
---

# Comics: Pick-A-Panel

_Updated val and test on 25/02/2025_

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). 
Please, check out our [๐Ÿš€ arxiv paper ๐Ÿš€](https://arxiv.org/abs/2503.08561) for more information ๐Ÿ˜Š 
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).

The dataset contains five subtask or skills:

<details>

<summary>Sequence Filling</summary>

![Sequence Filling](figures/seq_filling.png)

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.
</details>

<details>

<summary>Character Coherence, Visual Closure, Text Closure</summary>

![Character Coherence](figures/closure.png)

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:
- 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.
- 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.
- 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.

</details>

<details>

<summary>Caption Relevance</summary>

![Caption Relevance](figures/caption_relevance.png)

Given a caption from the previous panel, select the panel that best continues the story.
</details>

## Loading the Data

```python
from datasets import load_dataset

skill = "sequence_filling" # "sequence_filling", "char_coherence", "visual_closure", "text_closure", "caption_relevance"
split = "val" # "val", "test", "train"
dataset = load_dataset("VLR-CVC/ComicsPAP", skill, split=split)
```

<details>

<summary>Map to single images</summary>

If your model can only process single images, you can render each sample as a single image:

![Single Image Example](figures/single_image_seq_filling_example.png)


```python
from PIL import Image, ImageDraw, ImageFont
import numpy as np
from datasets import Features, Value, Image as ImageFeature

class SingleImagePickAPanel:
    def __init__(self, max_size=500, margin=10, label_space=20, font_path=None):
        if font_path is None:
            raise ValueError("Font path must be provided. Testing was done with 'Arial.ttf'")
        self.max_size = max_size
        self.margin = margin
        self.label_space = label_space
        # Add separate font sizes
        self.label_font_size = 20
        self.number_font_size = 24

        self.font_path = font_path

    def resize_image(self, img):
        """Resize image keeping aspect ratio if longest edge > max_size"""
        if max(img.size) > self.max_size:
            ratio = self.max_size / max(img.size)
            new_size = tuple(int(dim * ratio) for dim in img.size)
            return img.resize(new_size, Image.Resampling.LANCZOS)
        return img

    def create_mask_panel(self, width, height):
        """Create a question mark panel"""
        mask_panel = Image.new("RGB", (width, height), (200, 200, 200))
        draw = ImageDraw.Draw(mask_panel)
        font_size = int(height * 0.8)
        try:
            font = ImageFont.truetype(self.font_path, font_size)
        except:
            raise ValueError("Font file not found")
        
        text = "?"
        bbox = draw.textbbox((0, 0), text, font=font)
        text_x = (width - (bbox[2] - bbox[0])) // 2
        text_y = (height - (bbox[3] - bbox[1])) // 2
        draw.text((text_x, text_y), text, fill="black", font=font)
        return mask_panel

    def draw_number_on_panel(self, panel, number, font):
        """Draw number on the bottom of the panel with background"""
        draw = ImageDraw.Draw(panel)
        
        # Get text size
        bbox = draw.textbbox((0, 0), str(number), font=font)
        text_width = bbox[2] - bbox[0]
        text_height = bbox[3] - bbox[1]
        
        # Calculate position (bottom-right corner)
        padding = 2
        text_x = panel.size[0] - text_width - padding
        text_y = panel.size[1] - text_height - padding
        
        # Draw semi-transparent background
        bg_rect = [(text_x - padding, text_y - padding), 
                  (text_x + text_width + padding, text_y + text_height + padding)]
        draw.rectangle(bg_rect, fill=(255, 255, 255, 180))
        
        # Draw text
        draw.text((text_x, text_y), str(number), fill="black", font=font)
        return panel

    def map_to_single_image(self, examples):
        """Process a batch of examples from a HuggingFace dataset"""
        single_images = []
        
        for i in range(len(examples['sample_id'])):
            # Get context and options for current example
            context = examples['context'][i] if len(examples['context'][i]) > 0 else []
            options = examples['options'][i]
            
            # Resize all images
            context = [self.resize_image(img) for img in context]
            options = [self.resize_image(img) for img in options]
            
            # Calculate common panel size (use median size to avoid outliers)
            all_panels = context + options
            if len(all_panels) > 0:
                widths = [img.size[0] for img in all_panels]
                heights = [img.size[1] for img in all_panels]
                panel_width = int(np.median(widths))
                panel_height = int(np.median(heights))
                
                # Resize all panels to common size
                context = [img.resize((panel_width, panel_height)) for img in context]
                options = [img.resize((panel_width, panel_height)) for img in options]
                
                # Create mask panel for sequence filling tasks if needed
                if 'index' in examples and len(context) > 0:
                    mask_idx = examples['index'][i]
                    mask_panel = self.create_mask_panel(panel_width, panel_height)
                    context.insert(mask_idx, mask_panel)
                
                # Calculate canvas dimensions based on whether we have context
                if len(context) > 0:
                    context_row_width = panel_width * len(context) + self.margin * (len(context) - 1)
                    options_row_width = panel_width * len(options) + self.margin * (len(options) - 1)
                    canvas_width = max(context_row_width, options_row_width)
                    canvas_height = (panel_height * 2 + 
                                   self.label_space * 2)
                else:
                    # Only options row for caption_relevance
                    canvas_width = panel_width * len(options) + self.margin * (len(options) - 1)
                    canvas_height = (panel_height + 
                                   self.label_space)
                
                # Create canvas
                final_image = Image.new("RGB", (canvas_width, canvas_height), "white")
                draw = ImageDraw.Draw(final_image)
                
                try:
                    label_font = ImageFont.truetype(self.font_path, self.label_font_size)
                    number_font = ImageFont.truetype(self.font_path, self.number_font_size)
                except:
                    raise ValueError("Font file not found")
                
                current_y = 0
                
                # Add context section if it exists
                if len(context) > 0:
                    # Draw "Context" label
                    bbox = draw.textbbox((0, 0), "Context", font=label_font)
                    text_x = (canvas_width - (bbox[2] - bbox[0])) // 2
                    draw.text((text_x, current_y), "Context", fill="black", font=label_font)
                    current_y += self.label_space
                    
                    # Paste context panels
                    x_offset = (canvas_width - (panel_width * len(context) + 
                               self.margin * (len(context) - 1))) // 2
                    for panel in context:
                        final_image.paste(panel, (x_offset, current_y))
                        x_offset += panel_width + self.margin
                    current_y += panel_height
                
                # Add "Options" label
                bbox = draw.textbbox((0, 0), "Options", font=label_font)
                text_x = (canvas_width - (bbox[2] - bbox[0])) // 2
                draw.text((text_x, current_y), "Options", fill="black", font=label_font)
                current_y += self.label_space
                
                # Paste options with numbers on panels
                x_offset = (canvas_width - (panel_width * len(options) + 
                           self.margin * (len(options) - 1))) // 2
                for idx, panel in enumerate(options):
                    # Create a copy of the panel to draw on
                    panel_with_number = panel.copy()
                    if panel_with_number.mode != 'RGBA':
                        panel_with_number = panel_with_number.convert('RGBA')
                    
                    # Draw number on panel
                    panel_with_number = self.draw_number_on_panel(
                        panel_with_number, 
                        idx, 
                        number_font
                    )
                    
                    # Paste the panel with number
                    final_image.paste(panel_with_number, (x_offset, current_y), panel_with_number)
                    x_offset += panel_width + self.margin
                
                # Convert final_image to PIL Image format (instead of numpy array)
                single_images.append(final_image)
            
        # Prepare batch output
        examples['single_image'] = single_images
        
        return examples

from datasets import load_dataset

skill = "sequence_filling" # "sequence_filling", "char_coherence", "visual_closure", "text_closure", "caption_relevance"
split = "val" # "val", "test"
dataset = load_dataset("VLR-CVC/ComicsPAP", skill, split=split)

processor = SingleImagePickAPanel()
dataset = dataset.map(
        processor.map_to_single_image,
        batched=True,
        batch_size=32,
        remove_columns=['context', 'options']
    )
dataset.save_to_disk(f"ComicsPAP_{skill}_{split}_single_images")
```

</details>

## Evaluation

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.

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:

```json
[
    { "sample_id" : "sample_id_0", "correct_panel_id" : 3},
    { "sample_id" : "sample_id_1", "correct_panel_id" : 1},
    { "sample_id" : "sample_id_2", "correct_panel_id" : 4},
    ...,
]
```

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. 

<details>

<summary>Pseudocode for the evaluation on val set, adapt for your model:</summary>

```python
skills = {
    "sequence_filling": {
        "num_examples": 262
    },
    "char_coherence": {
        "num_examples": 143
    },
    "visual_closure": {
        "num_examples": 300
    },
    "text_closure": {
        "num_examples": 259
    },
    "caption_relevance": {
        "num_examples": 262
    }
}

for skill in skills:
    dataset = load_dataset("VLR-CVC/ComicsPAP", skill, split="val")
    correct = 0
    total = 0
    for example in dataset:
        # Your model prediction
        prediction = model.generate(**example)
        prediction = post_process(prediction)
        if prediction == example["solution_index"]:
            correct += 1
        total += 1
    accuracy = correct / total
    print(f"Accuracy for {skill}: {accuracy}")

    assert total == skills[skill]["num_examples"]
    skills[skill]["accuracy"] = accuracy

# Calculate overall accuracy
total_examples = sum(skill["num_examples"] for skill in skills.values())
overall_accuracy = sum(skill["num_examples"] * skill["accuracy"] for skill in skills.values()) / total_examples
print(f"Overall accuracy: {overall_accuracy}")
    
```

</details>

## Baselines

Find code for evaluation and training at: [https://github.com/llabres/ComicsPAP](https://github.com/llabres/ComicsPAP)

Baselines on the validation set using single images:

|           Model            |                                        Repo                                         | Sequence Filling (%) | Character Coherence (%) | Visual Closure (%) | Text Closure (%) | Caption Relevance (%) | Total (%) |
| :------------------------: | :---------------------------------------------------------------------------------: | :------------------: | :---------------------: | :----------------: | :--------------: | :-------------------: | :-------: |
|           Random           |                                                                                     |        20.22         |          50.00          |       14.41        |      25.00       |         25.00         |   24.30   |
| 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   |
| 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   |
| 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   |
| 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 |
| 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** |

## Citation
If you use the dataset, please cite our work :
```bibtex
@article{vivoli2025comicspap,
  title={ComicsPAP: understanding comic strips by picking the correct panel}, 
  author={Emanuele Vivoli and Artemis Llabrรฉs and Mohamed Ali Soubgui and Marco Bertini and Ernest Valveny Llobet and Dimosthenis Karatzas},
  journal={arXiv preprint arXiv:2503.08561},
  year={2025},
}
```