File size: 2,127 Bytes
043a3dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7d9a646
 
 
 
 
 
 
 
 
 
 
043a3dd
7d9a646
 
 
 
 
 
055e85a
 
7d9a646
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
055e85a
 
 
 
 
 
 
 
 
 
 
 
390d61b
 
055e85a
 
7d9a646
 
 
 
 
 
 
 
 
 
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
---
dataset_info:
  features:
  - name: image
    dtype: image
  - name: text
    dtype: string
  splits:
  - name: train
    num_bytes: 356575908.28
    num_examples: 6315
  download_size: 333299098
  dataset_size: 356575908.28
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
license: cc-by-sa-3.0
task_categories:
- text-to-image
language:
- en
- ja
tags:
- kanji
pretty_name: Kanji images with textual descriptions
size_categories:
- 1K<n<10K
---

# KanjiVG PNG images with textual descriptions
This dataset is an adaptation of [KanjiVG](https://github.com/KanjiVG/kanjivg) by Ulrich Apel. The original SVG files have been converted to 1024x1024 PNG images and enriched with Kanji descriptions of their meaning.

## Usage
```python
>>> import datasets
>>> data = datasets.load_dataset("davidstap/kanji_definitions")
>>> data
DatasetDict({
    train: Dataset({
        features: ['image', 'text'],
        num_rows: 6315
    })
})
>>> data['train']
Dataset({
    features: ['image', 'text'],
    num_rows: 6315
})
>>> data['train']['text'][0]
'bamboo rice basket'
>>> data['train']['image'][0]
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=1024x1024 at 0x7F1B037E5600>
```


Note that some kanji characters have multiple meanings, which are separated by commas. You can expand entries to include the same image for each meaning by doing:

```python
>>> new_data = (
...     datasets.Dataset.from_dict(
...         {
...             'image': [img for img, txt in zip(data['train']['image'], data['train']['text']) for _ in txt.split(',')],
...             'text':  [desc.strip() for txt in data['train']['text'] for desc in txt.split(',')]
...         }
...     )
... )
>>> len(new_data)
16168
```

## Modifications from Original
- Converted SVG files to 1024x1024 PNG format
- Added descriptive text for each Kanji character
- Removed numbering from SVG renders
- Original vector graphics available at: https://github.com/KanjiVG/kanjivg

## Attribution
- Original work: KanjiVG by Ulrich Apel
- Original repository: https://github.com/KanjiVG/kanjivg
- Adaptation by: David Stap