Datasets:
Dataset Card for CLIPCJK_Gen
Dataset summary
The CLIPCJK_Gen Dataset is a Japanese-language dataset of images generated from 17 japanese fonts and is supposedly used to train a CLIP-like model for japanese character recognition. This dataset contains 2414 classes representing mostly Japanese characters but also punctuation, latin alphabet, etc.
How to use
This dataset is stored in the WebDataset
format. To use it, you need to install the webdataset
and huggingface_hub
libraries.
pip install webdataset huggingface_hub
You can then stream the data directly from the Hub like this:
import torch
import webdataset as wds
from huggingface_hub import hf_hub_url, get_dataset_repo_info
from torchvision import transforms
from PIL import Image
repo_id = "amaurygau/ClipCJK_Gen"
info = get_dataset_repo_info(repo_id)
split = "train" # or "test"
shard_urls = [
hf_hub_url(repo_id, f)
for f in info.siblings
if f.rfilename.startswith(f"{split}/") and f.rfilename.endswith(".tar")
]
# Create the webdataset pipeline
dataset = wds.WebDataset(shard_urls)
.shuffle(1000)
.decode("pil")
.to_tuple("png", "json")
# iterate over the dataset
dataset_iterator = iter(dataset)
first_sample = next(dataset_iterator)
print(firt_sample)
## Example Output
# (<PIL.Image.Image image mode=RGB size=224x224>,
# {'filepath': '剛/剛_5.png', 'title': '剛:⿰岡刂'})
Dataset structure
Data instances
A data point comprises a path to an image with its label (that we call title). A sample looks like this:
{'__key__': 'sample_00089001',
'__url__': 'train/train-000089.tar',
'json': {'filepath': '剛/剛_5.png', 'title': '剛:⿰岡刂'},
'__local_path__': 'train/train-000089.tar',
'png': <PIL.Image.Image image mode=RGB size=224x224>}
Data fields
__key__
: the unique identifier of the sample inside the shard.__url__
: the path to the shard (.tar file) containing the sample.json
: a dictionary containing metadata. The title field holds the character's label, including its IDS decomposition.__local_path__
: the path to the samplepng
: the raw image data in bytes. Can be decoded into a PIL.Image object.
Data Splits
Train | Test | |
---|---|---|
Classes | 2414 | 2414 |
Image Files | 76392 | 15614 |
Labels | 305565 | 35629 |
Note: The number of labels is higher than the number of images because each label is duplicated to match the character with the highest number of IDS patterns, as explained in the 'Label Biases' section
Dataset Creation
ClipCJK_Gen was built to provide enough date for an OpenCLIP VLM to predict and recognize Japanese Characters.
Source Data
Initial Data collection
The dataset was built by generating images of shape 224*224 of characters from 17 Japanese fonts listed here :
- Daichi. « ダーツフォント ». ProjectDARTS, 2024, https://www.p-darts.jp/font/dartsfont/. TTF.
- Electronic Font Open Laboratory. « Sazanami Mincho ». Version 001, 2004, https://www.wazu.jp/gallery/Fonts_Japanese2.html. TTF.
- Fontrix. « LINESeedJP_A ». 2022, https://seed.line.me/. TTF.
- Furukawa, Yasuyuki. « Kochi Gothic Substitute ». 2003. TTF.
- Inconnu. « 851マカポップ ». Version 1.01, 2022, https://pm85122.onamae.jp/851mkpop.html. TTF.
- ———. « Aoyagi Kouzan Font 2 OTF ». Version 1.1, 2015, https://jref.com/resources/aoyagi-kouzan.90/. OTF.
- ———. « Nagurigaki ». Version 1.60, 2007, https://www.wazu.jp/gallery/Fonts_Japanese2.html. TTF.
- ———. « Osaka_unicode ». Version 1. TTF.
- ———. « Sea font ». Version 1.60, https://www.wazu.jp/gallery/Fonts_Japanese2.html. TTF.
- Kataoka, Yuji. « YujiBoku ». 28 novembre 2019. Kinutafontfactory, 2024. GitHub, https://github.com/Kinutafontfactory/Yuji. TTF.
- Kurrasch, Jim. « Sword Kanji ». Avec Didier Mas, 2002, http://didier.mas.free.fr/public/. TTC.
- Masayuki Sato et Hiroko Takiguchi. « Holiday-MDJP05 ». Version 05, 2014, https://mksd.jp/holiday05.html. OTF.
- Momo. « さるじふぉんと ». Avec Chitose Kato, 2022, https://note.com/chitosekato/n/nc162552f8c1f. TTF.
- Okita Kana. « ラコフォント ». 2016, https://okitan.booth.pm/items/203082. TTF.
- Shibuya Myam. « 左利きの彼女 ». Police de caractères. 2022, https://note.com/shibumi/n/nb2ba54baf3c6. OTF.
- YOKO. « YOKO文字 ». Avec Chitose Kato, 2022, https://note.com/chitosekato/n/nc162552f8c1f. TTF.
- ZHONGYI Electronic Co. « Simsun ». Avec Microsoft, 2001, https://learn.microsoft.com/fr-be/typography/font-list/simsun. TTC.
Data Annotation
All the data is annotated with the character from its Unicode code point. To which we then labels constructed with IDS from the CHISE project. Such as a label follows the rule Char:Char
or Char:Char
giving the following labels :
剛:剛
剛:⿰岡刂
Annotation Process
The code for annotation can be found here.
Considerations for using the Data
Label biases
Some of the characters do not possess the same number of IDS patterns possibles. Some possess 3 different patterns, some others none. In this case, to let any model view the same number of times a given image, we copy the first label as many times as necessary.
Cropped images
Some of the characters were not fully generated, and just a part of the character is visible. You can think of it as a forced data augmentation config for VLM models =D
Licensing Information
The licensing status of the dataset hinges on the legal status of the fonts' designers, which should be free for non-commercial use. So please, cite them.
- Downloads last month
- 18