popmanga_test / README.md
ragavsachdeva's picture
Update README.md
898b1b0 verified
metadata
extra_gated_fields:
  University or affiliation: text
  I agree to use this dataset for academic and non-commercial use ONLY: checkbox

PopManga (Test)

from datasets import load_dataset
from PIL import Image
import numpy as np
    
def read_image(path_to_image):
    with open(path_to_image, "rb") as file:
        image = Image.open(file).convert("L").convert("RGB")
        image = np.array(image)
    return image

if __name__ == "__main__":
    dataset = load_dataset("ragavsachdeva/popmanga_test", trust_remote_code=True) # the first time you run this, it will download the images from mangaplus
    split = "seen" # "unseen"
    for b, example in enumerate(dataset[split]):
        image_path, magi_annotations, character_clusters, text_char_matches, text_tail_matches, text_classification, character_names = example.values()
        image = read_image(image_path)
        character_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 0]
        text_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 1]
        panel_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 2] # these are generated by the model (included for convenience)
        tail_bboxes = [bbox for bbox, label in zip(magi_annotations["bboxes_as_x1y1x2y2"], magi_annotations["labels"]) if label == 3]

Citation

@InProceedings{magiv1,
    author    = {Sachdeva, Ragav and Zisserman, Andrew},
    title     = {The Manga Whisperer: Automatically Generating Transcriptions for Comics},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2024},
    pages     = {12967-12976}
}
@misc{magiv2,
      author={Ragav Sachdeva and Gyungin Shin and Andrew Zisserman},
      title={Tails Tell Tales: Chapter-Wide Manga Transcriptions with Character Names}, 
      year={2024},
      eprint={2408.00298},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2408.00298}, 
}