kyamagu commited on
Commit
e33b4b8
1 Parent(s): 9099d46

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -40
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
- **Context features (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 sequence features |
822
-
823
- **Sequence features (Element attributes)**
824
-
825
- | Field | Type | Shape | Description |
826
- | -------------- | ----------- | ----- | -------------------------------------------------------------------- |
827
- | type | categorical | () | Element type, such as vector shape, image, or text |
828
- | left | float32 | () | Element left position normalized to [0, 1] range w.r.t. canvas_width |
829
- | top | float32 | () | Element top position normalized to [0, 1] range w.r.t. canvas_height |
830
- | width | float32 | () | Element width normalized to [0, 1] range w.r.t. canvas_width |
831
- | height | float32 | () | Element height normalized to [0, 1] range w.r.t. canvas_height |
832
- | color | int64 | (3,) | Extracted main RGB color of the element |
833
- | opacity | float32 | () | Opacity in [0, 1] range |
834
- | image_bytes | image | () | Pre-rendered 256x256 preview of the element encoded in PNG format |
835
- | text | string | () | Text content in UTF-8 encoding for text element |
836
- | font | categorical | () | Font family name for text element |
837
- | font_size | float32 | () | Font size (height) in pixels |
838
- | text_align | categorical | () | Horizontal text alignment, left, center, right for text element |
839
- | angle | float32 | () | Element rotation angle (radian) w.r.t. the center of the element |
840
- | capitalize | categorical | () | Binary flag to capitalize letters |
841
- | line_height | float32 | () | Scaling parameter to line height, default is 1.0 |
842
- | letter_spacing | float32 | () | Adjustment parameter for letter spacing, default is 0.0 |
 
 
 
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(dataset: datasets.Dataset, example: Dict[str, Any], max_size: float=512.) -> bytes:
876
  """Render parsed sequence example onto an image and return as PNG bytes."""
877
- canvas_width = int(dataset.features["canvas_width"].int2str(example["canvas_width"]))
878
- canvas_height = int(dataset.features["canvas_height"].int2str(example["canvas_height"]))
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 8, 2023)
978
 
979
  - Migrate to Hugging Face Hub.
980
- - Improve text rendering quality.
981
- - Change split generation criteria: no compatibility with v2 splits.
982
  - Incorporate a motion picture thumbnail in templates.
983
- - Add `capitalize`, `line_height`, and `letter_spacing` sequence attributes.
 
984
 
985
  2.0: v2 release (May 26, 2022)
986
 
987
- - Add `text`, `font`, `font_size`, `text_align`, and `angle` sequence attributes.
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)