Datasets:
Update README.md
Browse files
README.md
CHANGED
@@ -567,15 +567,7 @@ The Crello dataset is compiled for the study of vector graphic documents. The da
|
|
567 |
```python
|
568 |
import datasets
|
569 |
|
570 |
-
dataset = datasets.load_dataset("cyberagent/crello")
|
571 |
-
```
|
572 |
-
|
573 |
-
Old revision is available via `revision` option.
|
574 |
-
|
575 |
-
```python
|
576 |
-
import datasets
|
577 |
-
|
578 |
-
dataset = datasets.load_dataset("cyberagent/crello", revision="3.1")
|
579 |
```
|
580 |
|
581 |
### Supported Tasks and Leaderboards
|
@@ -590,110 +582,15 @@ Almost all design templates use English.
|
|
590 |
|
591 |
### Data Instances
|
592 |
|
593 |
-
Each instance has scalar attributes (canvas) and sequence attributes (elements).
|
594 |
-
|
595 |
-
```
|
596 |
-
{'id': '592d6c2c95a7a863ddcda140',
|
597 |
-
'length': 8,
|
598 |
-
'group': 4,
|
599 |
-
'format': 20,
|
600 |
-
'canvas_width': 3,
|
601 |
-
'canvas_height': 1,
|
602 |
-
'category': 0,
|
603 |
-
'title': 'Beauty Blog Ad Woman with Unusual Hairstyle',
|
604 |
-
'type': [1, 3, 3, 3, 3, 4, 4, 4],
|
605 |
-
'left': [0.0,
|
606 |
-
-0.0009259259095415473,
|
607 |
-
0.24444444477558136,
|
608 |
-
0.5712962746620178,
|
609 |
-
0.2657407522201538,
|
610 |
-
0.369228333234787,
|
611 |
-
0.2739444375038147,
|
612 |
-
0.44776931405067444],
|
613 |
-
'top': [0.0,
|
614 |
-
-0.0009259259095415473,
|
615 |
-
0.37037035822868347,
|
616 |
-
0.41296297311782837,
|
617 |
-
0.41296297311782837,
|
618 |
-
0.8946287035942078,
|
619 |
-
0.4549448788166046,
|
620 |
-
0.40591198205947876],
|
621 |
-
'width': [1.0,
|
622 |
-
1.0018517971038818,
|
623 |
-
0.510185182094574,
|
624 |
-
0.16296295821666718,
|
625 |
-
0.16296295821666718,
|
626 |
-
0.30000001192092896,
|
627 |
-
0.4990740716457367,
|
628 |
-
0.11388888955116272],
|
629 |
-
'height': [1.0,
|
630 |
-
1.0018517971038818,
|
631 |
-
0.25833332538604736,
|
632 |
-
0.004629629664123058,
|
633 |
-
0.004629629664123058,
|
634 |
-
0.016611294820904732,
|
635 |
-
0.12458471953868866,
|
636 |
-
0.02657807245850563],
|
637 |
-
'opacity': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
|
638 |
-
'text': ['', '', '', '', '', 'STAY WITH US', 'FOLLOW', 'PRESS'],
|
639 |
-
'font': [0, 0, 0, 0, 0, 152, 172, 152],
|
640 |
-
'font_size': [0.0, 0.0, 0.0, 0.0, 0.0, 18.0, 135.0, 30.0],
|
641 |
-
'text_align': [0, 0, 0, 0, 0, 2, 2, 2],
|
642 |
-
'angle': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
|
643 |
-
'capitalize': [0, 0, 0, 0, 0, 0, 0, 0],
|
644 |
-
'line_height': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
|
645 |
-
'letter_spacing': [0.0, 0.0, 0.0, 0.0, 0.0, 14.0, 12.55813980102539, 3.0],
|
646 |
-
'suitability': [0],
|
647 |
-
'keywords': ['beautiful',
|
648 |
-
'beauty',
|
649 |
-
'blog',
|
650 |
-
'blogging',
|
651 |
-
'caucasian',
|
652 |
-
'cute',
|
653 |
-
'elegance',
|
654 |
-
'elegant',
|
655 |
-
'fashion',
|
656 |
-
'fashionable',
|
657 |
-
'femininity',
|
658 |
-
'glamour',
|
659 |
-
'hairstyle',
|
660 |
-
'luxury',
|
661 |
-
'model',
|
662 |
-
'stylish',
|
663 |
-
'vogue',
|
664 |
-
'website',
|
665 |
-
'woman',
|
666 |
-
'post',
|
667 |
-
'instagram',
|
668 |
-
'ig',
|
669 |
-
'insta',
|
670 |
-
'fashion',
|
671 |
-
'purple'],
|
672 |
-
'industries': [1, 8, 13],
|
673 |
-
'color': [[153.0, 118.0, 96.0],
|
674 |
-
[34.0, 23.0, 61.0],
|
675 |
-
[34.0, 23.0, 61.0],
|
676 |
-
[255.0, 255.0, 255.0],
|
677 |
-
[255.0, 255.0, 255.0],
|
678 |
-
[255.0, 255.0, 255.0],
|
679 |
-
[255.0, 255.0, 255.0],
|
680 |
-
[255.0, 255.0, 255.0]],
|
681 |
-
'image': [<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>,
|
682 |
-
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>,
|
683 |
-
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>,
|
684 |
-
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>,
|
685 |
-
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>,
|
686 |
-
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>,
|
687 |
-
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>,
|
688 |
-
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=256x256>]}
|
689 |
-
```
|
690 |
|
691 |
To get a label for categorical values, use the `int2str` method:
|
692 |
|
693 |
```python
|
694 |
data = dataset['train'] # obtain the train set
|
695 |
key = "font"
|
696 |
-
example = data[0] # obtain first sample in train set
|
697 |
|
698 |
data.features[key].feature.int2str(example[key]) # obtain the text equivalent of the encoded values
|
699 |
```
|
@@ -704,109 +601,83 @@ In the following, categorical fields are shown as `categorical` type, but the ac
|
|
704 |
|
705 |
**Canvas attributes**
|
706 |
|
707 |
-
| Field | Type | Shape | Description
|
708 |
-
| ------------- | ----------- | ------- |
|
709 |
-
| id | string | () | Template ID from
|
710 |
-
| group | categorical | () | Broad design groups, such as social media posts or blog headers
|
711 |
-
| format | categorical | () | Detailed design formats, such as Instagram post or postcard
|
712 |
-
| category | categorical | () | Topic category of the design, such as holiday celebration
|
713 |
-
| canvas_width |
|
714 |
-
| canvas_height |
|
715 |
-
| length | int64 | () | Length of elements
|
716 |
-
| suitability | categorical | (None,) | List of display tags, only `mobile` tag exists
|
717 |
-
| keywords | string | (None,) | List of keywords associated to this template
|
718 |
-
| industries | categorical | (None,) | List of industry tags like `marketingAds`
|
719 |
-
| preview | image | () | Preview image of the template for convenience
|
720 |
-
| cluster_index | int64 | () | Cluster index used to split the dataset; only for debugging
|
721 |
|
722 |
**Element attributes**
|
723 |
|
724 |
-
| Field | Type | Shape
|
725 |
-
| -------------- | ----------- |
|
726 |
-
| type | categorical | (None,)
|
727 |
-
| left | float32 | (None,)
|
728 |
-
| top | float32 | (None,)
|
729 |
-
| width | float32 | (None,)
|
730 |
-
| height | float32 | (None,)
|
731 |
-
| color |
|
732 |
-
| opacity | float32 | (None,)
|
733 |
-
| image | image | (None,)
|
734 |
-
| text | string | (None,)
|
735 |
-
| font | categorical | (None,)
|
736 |
-
| font_size | float32 | (None,)
|
737 |
-
| text_align | categorical | (None,)
|
738 |
-
| angle | float32 | (None,)
|
739 |
-
|
|
740 |
-
|
|
741 |
-
|
|
742 |
-
|
743 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
744 |
|
745 |
```
|
746 |
https://create.vista.com/artboard/?template=<template_id>
|
747 |
```
|
748 |
|
749 |
-
`left` and `top` can be negative because elements can be bigger than the canvas size.
|
750 |
-
|
751 |
### Data Splits
|
752 |
|
753 |
The Crello dataset has 3 splits: train, validation, and test. The current split is generated based on appearance-based clustering.
|
754 |
|
755 |
| Split | Count |
|
756 |
| --------- | ----- |
|
757 |
-
| train |
|
758 |
-
| validaton |
|
759 |
-
| test |
|
760 |
-
|
761 |
|
762 |
### Visualization
|
763 |
|
764 |
-
Each example can be visualized in the following approach using [`
|
765 |
|
766 |
-
|
767 |
-
import io
|
768 |
-
from typing import Any, Dict
|
769 |
-
|
770 |
-
import numpy as np
|
771 |
-
import skia
|
772 |
-
|
773 |
-
|
774 |
-
def render(features: datasets.Features, example: Dict[str, Any], max_size: float=512.) -> bytes:
|
775 |
-
"""Render parsed sequence example onto an image and return as PNG bytes."""
|
776 |
-
canvas_width = int(features["canvas_width"].int2str(example["canvas_width"]))
|
777 |
-
canvas_height = int(features["canvas_height"].int2str(example["canvas_height"]))
|
778 |
-
|
779 |
-
scale = min(1.0, max_size / canvas_width, max_size / canvas_height)
|
780 |
-
|
781 |
-
surface = skia.Surface(int(scale * canvas_width), int(scale * canvas_height))
|
782 |
-
with surface as canvas:
|
783 |
-
canvas.scale(scale, scale)
|
784 |
-
for index in range(example["length"]):
|
785 |
-
pil_image = example["image"][index]
|
786 |
-
image = skia.Image.frombytes(
|
787 |
-
pil_image.convert('RGBA').tobytes(),
|
788 |
-
pil_image.size,
|
789 |
-
skia.kRGBA_8888_ColorType)
|
790 |
-
left = example["left"][index] * canvas_width
|
791 |
-
top = example["top"][index] * canvas_height
|
792 |
-
width = example["width"][index] * canvas_width
|
793 |
-
height = example["height"][index] * canvas_height
|
794 |
-
rect = skia.Rect.MakeXYWH(left, top, width, height)
|
795 |
-
paint = skia.Paint(Alphaf=example["opacity"][index], AntiAlias=True)
|
796 |
-
|
797 |
-
angle = example["angle"][index]
|
798 |
-
with skia.AutoCanvasRestore(canvas):
|
799 |
-
if angle != 0:
|
800 |
-
degree = 180. * angle / np.pi
|
801 |
-
canvas.rotate(degree, left + width / 2., top + height / 2.)
|
802 |
-
canvas.drawImageRect(image, rect, paint=paint)
|
803 |
-
|
804 |
-
image = surface.makeImageSnapshot()
|
805 |
-
with io.BytesIO() as f:
|
806 |
-
image.save(f, skia.kPNG)
|
807 |
-
return f.getvalue()
|
808 |
-
```
|
809 |
|
|
|
|
|
810 |
|
811 |
## Dataset Creation
|
812 |
|
@@ -874,6 +745,17 @@ We do not re-distribute the original files as we are not allowed by terms.
|
|
874 |
|
875 |
### Releases
|
876 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
877 |
4.0.0: v4 release (Dec 5, 2023)
|
878 |
|
879 |
- Change the dataset split based on the template appearance to avoid near-duplicates: no compatibility with v3.
|
|
|
567 |
```python
|
568 |
import datasets
|
569 |
|
570 |
+
dataset = datasets.load_dataset("cyberagent/crello", revision="5.0.0")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
```
|
572 |
|
573 |
### Supported Tasks and Leaderboards
|
|
|
582 |
|
583 |
### Data Instances
|
584 |
|
585 |
+
Each instance has scalar attributes (canvas) and sequence attributes (elements).
|
586 |
+
Categorical values are stored as integer values. Check `ClassLabel` features of the dataset for the list of categorical labels.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
|
588 |
To get a label for categorical values, use the `int2str` method:
|
589 |
|
590 |
```python
|
591 |
data = dataset['train'] # obtain the train set
|
592 |
key = "font"
|
593 |
+
example = data[0] # obtain the first sample in train set
|
594 |
|
595 |
data.features[key].feature.int2str(example[key]) # obtain the text equivalent of the encoded values
|
596 |
```
|
|
|
601 |
|
602 |
**Canvas attributes**
|
603 |
|
604 |
+
| Field | Type | Shape | Description |
|
605 |
+
| ------------- | ----------- | ------- | --------------------------------------------------------------- |
|
606 |
+
| id | string | () | Template ID from create.vista.com |
|
607 |
+
| group | categorical | () | Broad design groups, such as social media posts or blog headers |
|
608 |
+
| format | categorical | () | Detailed design formats, such as Instagram post or postcard |
|
609 |
+
| category | categorical | () | Topic category of the design, such as holiday celebration |
|
610 |
+
| canvas_width | int64 | () | Canvas pixel width |
|
611 |
+
| canvas_height | int64 | () | Canvas pixel height |
|
612 |
+
| length | int64 | () | Length of elements |
|
613 |
+
| suitability | categorical | (None,) | List of display tags, only `mobile` tag exists |
|
614 |
+
| keywords | string | (None,) | List of keywords associated to this template |
|
615 |
+
| industries | categorical | (None,) | List of industry tags like `marketingAds` |
|
616 |
+
| preview | image | () | Preview image of the template for convenience |
|
617 |
+
| cluster_index | int64 | () | Cluster index used to split the dataset; only for debugging |
|
618 |
|
619 |
**Element attributes**
|
620 |
|
621 |
+
| Field | Type | Shape | Description |
|
622 |
+
| -------------- | ----------- | ------------ | ---------------------------------------------------------------- |
|
623 |
+
| type | categorical | (None,) | Element type, such as vector shape, image, or text |
|
624 |
+
| left | float32 | (None,) | Element left position |
|
625 |
+
| top | float32 | (None,) | Element top position |
|
626 |
+
| width | float32 | (None,) | Element width |
|
627 |
+
| height | float32 | (None,) | Element height |
|
628 |
+
| color | string | (None, None) | RGB color palette of the vector graphic element |
|
629 |
+
| opacity | float32 | (None,) | Opacity in [0, 1] range |
|
630 |
+
| image | image | (None,) | Pre-rendered preview of the element encoded in PNG format |
|
631 |
+
| text | string | (None,) | Text content in UTF-8 encoding for text element |
|
632 |
+
| font | categorical | (None,) | Font family name for text element |
|
633 |
+
| font_size | float32 | (None,) | Font size (height) in pixels |
|
634 |
+
| text_align | categorical | (None,) | Horizontal text alignment, left, center, right for text element |
|
635 |
+
| angle | float32 | (None,) | Element rotation angle (degree) w.r.t. the center of the element |
|
636 |
+
| font_bold | boolean | (None, None) | Character-wise flag to indicate bold font |
|
637 |
+
| font_italic | boolean | (None, None) | Character-wise flag to indicate italic font |
|
638 |
+
| text_color | string | (None, None) | Character-wise rgba color |
|
639 |
+
| text_line | int64 | (None, None) | Character-wise index of line number |
|
640 |
+
| capitalize | boolean | (None,) | Binary flag to capitalize letters |
|
641 |
+
| line_height | float32 | (None,) | Scaling parameter to line height, default is 1.0 |
|
642 |
+
| letter_spacing | float32 | (None,) | Adjustment parameter for letter spacing, default is 0.0 |
|
643 |
+
|
644 |
+
`left` and `top` can be negative because elements can be bigger than the canvas size.
|
645 |
+
`text_line` indicates the index of the text line.
|
646 |
+
For example, the following indicates that `Be` is in the first line and the rest in the next line.
|
647 |
+
The newline character `\n` if present is ignored in rendering.
|
648 |
+
|
649 |
+
```
|
650 |
+
{
|
651 |
+
"text": "Be\nambitious!",
|
652 |
+
"text_line": [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
653 |
+
}
|
654 |
+
```
|
655 |
+
|
656 |
+
Note that the color and pre-rendered images do not necessarily accurately reproduce the original design templates.
|
657 |
+
The original template is accessible at the following URL if still available.
|
658 |
|
659 |
```
|
660 |
https://create.vista.com/artboard/?template=<template_id>
|
661 |
```
|
662 |
|
|
|
|
|
663 |
### Data Splits
|
664 |
|
665 |
The Crello dataset has 3 splits: train, validation, and test. The current split is generated based on appearance-based clustering.
|
666 |
|
667 |
| Split | Count |
|
668 |
| --------- | ----- |
|
669 |
+
| train | 19,421 |
|
670 |
+
| validaton | 1,875 |
|
671 |
+
| test | 2,006 |
|
|
|
672 |
|
673 |
### Visualization
|
674 |
|
675 |
+
Each example can be visualized in the following approach using [`cr-renderer`](https://github.com/CyberAgentAILab/cr-renderer).
|
676 |
|
677 |
+
https://github.com/CyberAgentAILab/cr-renderer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
678 |
|
679 |
+
Note the renderer does not guarantee a similar appearance to the original template.
|
680 |
+
Currently, the quality of text rendering is far from perfect.
|
681 |
|
682 |
## Dataset Creation
|
683 |
|
|
|
745 |
|
746 |
### Releases
|
747 |
|
748 |
+
5.0.0: v5 release (Sep 18, 2024)
|
749 |
+
|
750 |
+
- Element positions and sizes are not normalized by canvas size
|
751 |
+
- Angle is in degrees instead of radians.
|
752 |
+
- New rich-text attributes (font_bold, font_italic, font_color, text_line) that specify character-level styling
|
753 |
+
- Pre-rendered layer images are now resized to fit the longer side in 512px
|
754 |
+
- Significantly improved pre-rendering quality for each layer
|
755 |
+
- Color attribute now only contains palette when the original data has
|
756 |
+
- There are now five element types
|
757 |
+
- Dataset split is updated, no compatibility with v4.
|
758 |
+
|
759 |
4.0.0: v4 release (Dec 5, 2023)
|
760 |
|
761 |
- Change the dataset split based on the template appearance to avoid near-duplicates: no compatibility with v3.
|