Datasets:
Update README.md
Browse files
README.md
CHANGED
|
@@ -808,38 +808,41 @@ dataset.features[key].int2str(example[key])
|
|
| 808 |
|
| 809 |
In the following, categorical fields are shown as `categorical` type, but the actual storage is `int64`.
|
| 810 |
|
| 811 |
-
**
|
| 812 |
-
|
| 813 |
-
| Field | Type | Shape
|
| 814 |
-
| ------------- | ----------- |
|
| 815 |
-
| id | string | ()
|
| 816 |
-
| group | categorical | ()
|
| 817 |
-
| format | categorical | ()
|
| 818 |
-
| category | categorical | ()
|
| 819 |
-
| canvas_width | categorical | ()
|
| 820 |
-
| canvas_height | categorical | ()
|
| 821 |
-
| length | int64 | ()
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
|
| 829 |
-
|
|
| 830 |
-
|
|
| 831 |
-
|
|
| 832 |
-
|
|
| 833 |
-
|
|
| 834 |
-
|
|
| 835 |
-
|
|
| 836 |
-
|
|
| 837 |
-
|
|
| 838 |
-
|
|
| 839 |
-
|
|
| 840 |
-
|
|
| 841 |
-
|
|
| 842 |
-
|
|
|
|
|
|
|
|
|
|
|
| 843 |
|
| 844 |
Note that the color and pre-rendered images do not necessarily accurately reproduce the original design templates. The original template is accessible at the following URL if still available.
|
| 845 |
|
|
@@ -872,10 +875,10 @@ import numpy as np
|
|
| 872 |
import skia
|
| 873 |
|
| 874 |
|
| 875 |
-
def render(
|
| 876 |
"""Render parsed sequence example onto an image and return as PNG bytes."""
|
| 877 |
-
canvas_width = int(
|
| 878 |
-
canvas_height = int(
|
| 879 |
|
| 880 |
scale = min(1.0, max_size / canvas_width, max_size / canvas_height)
|
| 881 |
|
|
@@ -974,17 +977,18 @@ We do not re-distribute the original files as we are not allowed by terms.
|
|
| 974 |
|
| 975 |
### Releases
|
| 976 |
|
| 977 |
-
3.0: v3 release (Feb
|
| 978 |
|
| 979 |
- Migrate to Hugging Face Hub.
|
| 980 |
-
-
|
| 981 |
-
- Change split generation criteria: no compatibility with v2 splits.
|
| 982 |
- Incorporate a motion picture thumbnail in templates.
|
| 983 |
-
- Add `
|
|
|
|
| 984 |
|
| 985 |
2.0: v2 release (May 26, 2022)
|
| 986 |
|
| 987 |
-
- Add `text`, `font`, `font_size`, `text_align`, and `angle`
|
| 988 |
- Include rendered text element in `image_bytes`.
|
| 989 |
|
| 990 |
1.0: v1 release (Aug 24, 2021)
|
|
|
|
| 808 |
|
| 809 |
In the following, categorical fields are shown as `categorical` type, but the actual storage is `int64`.
|
| 810 |
|
| 811 |
+
**Canvas attributes**
|
| 812 |
+
|
| 813 |
+
| Field | Type | Shape | Description |
|
| 814 |
+
| ------------- | ----------- | ------- | -------------------------------------------------------------- |
|
| 815 |
+
| id | string | () | Template ID from crello.com |
|
| 816 |
+
| group | categorical | () | Broad design group, such as social media posts or blog headers |
|
| 817 |
+
| format | categorical | () | Detailed design format, such as Instagram post or postcard |
|
| 818 |
+
| category | categorical | () | Topic category of the design, such as holiday celebration |
|
| 819 |
+
| canvas_width | categorical | () | Canvas pixel width |
|
| 820 |
+
| canvas_height | categorical | () | Canvas pixel height |
|
| 821 |
+
| length | int64 | () | Length of elements |
|
| 822 |
+
| suitability | categorical | (None,) | List of display tags, only `mobile` tag exists |
|
| 823 |
+
| keywords | string | (None,) | List of keywords associated to this template |
|
| 824 |
+
| industries | categorical | (None,) | List of industry tags like `marketingAds` |
|
| 825 |
+
|
| 826 |
+
**Element attributes**
|
| 827 |
+
|
| 828 |
+
| Field | Type | Shape | Description |
|
| 829 |
+
| -------------- | ----------- | --------- | -------------------------------------------------------------------- |
|
| 830 |
+
| type | categorical | (None,) | Element type, such as vector shape, image, or text |
|
| 831 |
+
| left | float32 | (None,) | Element left position normalized to [0, 1] range w.r.t. canvas_width |
|
| 832 |
+
| top | float32 | (None,) | Element top position normalized to [0, 1] range w.r.t. canvas_height |
|
| 833 |
+
| width | float32 | (None,) | Element width normalized to [0, 1] range w.r.t. canvas_width |
|
| 834 |
+
| height | float32 | (None,) | Element height normalized to [0, 1] range w.r.t. canvas_height |
|
| 835 |
+
| color | int64 | (None, 3) | Extracted main RGB color of the element |
|
| 836 |
+
| opacity | float32 | (None,) | Opacity in [0, 1] range |
|
| 837 |
+
| image_bytes | image | (None,) | Pre-rendered 256x256 preview of the element encoded in PNG format |
|
| 838 |
+
| text | string | (None,) | Text content in UTF-8 encoding for text element |
|
| 839 |
+
| font | categorical | (None,) | Font family name for text element |
|
| 840 |
+
| font_size | float32 | (None,) | Font size (height) in pixels |
|
| 841 |
+
| text_align | categorical | (None,) | Horizontal text alignment, left, center, right for text element |
|
| 842 |
+
| angle | float32 | (None,) | Element rotation angle (radian) w.r.t. the center of the element |
|
| 843 |
+
| capitalize | categorical | (None,) | Binary flag to capitalize letters |
|
| 844 |
+
| line_height | float32 | (None,) | Scaling parameter to line height, default is 1.0 |
|
| 845 |
+
| letter_spacing | float32 | (None,) | Adjustment parameter for letter spacing, default is 0.0 |
|
| 846 |
|
| 847 |
Note that the color and pre-rendered images do not necessarily accurately reproduce the original design templates. The original template is accessible at the following URL if still available.
|
| 848 |
|
|
|
|
| 875 |
import skia
|
| 876 |
|
| 877 |
|
| 878 |
+
def render(features: datasets.Features, example: Dict[str, Any], max_size: float=512.) -> bytes:
|
| 879 |
"""Render parsed sequence example onto an image and return as PNG bytes."""
|
| 880 |
+
canvas_width = int(features["canvas_width"].int2str(example["canvas_width"]))
|
| 881 |
+
canvas_height = int(features["canvas_height"].int2str(example["canvas_height"]))
|
| 882 |
|
| 883 |
scale = min(1.0, max_size / canvas_width, max_size / canvas_height)
|
| 884 |
|
|
|
|
| 977 |
|
| 978 |
### Releases
|
| 979 |
|
| 980 |
+
3.0: v3 release (Feb 9, 2023)
|
| 981 |
|
| 982 |
- Migrate to Hugging Face Hub.
|
| 983 |
+
- Fix various text rendering bugs.
|
| 984 |
+
- Change split generation criteria for avoiding near-duplicates: no compatibility with v2 splits.
|
| 985 |
- Incorporate a motion picture thumbnail in templates.
|
| 986 |
+
- Add `title`, `keywords`, `suitability`, and `industries` canvas attributes.
|
| 987 |
+
- Add `capitalize`, `line_height`, and `letter_spacing` element attributes.
|
| 988 |
|
| 989 |
2.0: v2 release (May 26, 2022)
|
| 990 |
|
| 991 |
+
- Add `text`, `font`, `font_size`, `text_align`, and `angle` element attributes.
|
| 992 |
- Include rendered text element in `image_bytes`.
|
| 993 |
|
| 994 |
1.0: v1 release (Aug 24, 2021)
|