BCSS / README.md
Rvosuke's picture
Add image-embedded Parquet shards + configs block to enable Dataset Viewer
bdc4c6f verified
|
Raw
History Blame Contribute Delete
9.66 kB
metadata
license: mit
task_categories:
  - image-segmentation
language:
  - zh
tags:
  - chinese-calligraphy
  - stroke-segmentation
  - brush-calligraphy
  - handwriting
  - semantic-segmentation
pretty_name: Brush Calligraphy Stroke Segmentation (BCSS)
size_categories:
  - 1K<n<10K
configs:
  - config_name: train_val
    data_files:
      - split: train
        path: data/train_val/train-*.parquet
      - split: validation
        path: data/train_val/validation-*.parquet
      - split: test
        path: data/train_val/test-*.parquet
  - config_name: external_test
    data_files:
      - split: test
        path: data/external_test/test-*.parquet

Brush Calligraphy Stroke Segmentation Dataset (BCSS) πŸ–ŒοΈ

GitHub Paper License: MIT

This dataset card mirrors and is cross-linked with the project's GitHub repository: github.com/Rvosuke/BCSS.

Introduction

The Brush Calligraphy Stroke Segmentation Dataset (BCSS) is a resource for the task of Chinese brush-calligraphy stroke segmentation. It is derived from the Evaluated Chinese Calligraphy Copies (E3C) dataset β€” an aesthetic-evaluation dataset for Chinese brush calligraphy β€” and augmented with additional images from diverse sources to enhance diversity and support the evaluation of model generalization.

Each character image is paired with a set of per-stroke binary masks, enabling multi-label stroke segmentation where intersecting strokes can overlap. A per-character prior-knowledge vector (stroke-count metadata) is also provided.

What's in this HuggingFace copy

The full BCSS dataset described in the paper contains 1,322 images and 10,653 annotated strokes. This HuggingFace release packages the segmentation-ready split that ships with the reference implementation:

Subset Images Notes
Training + Validation 1,082 Each image has 6 per-stroke masks + a prior-knowledge vector row
External Testing 130 Held-out generalization images (input images only)
Total 1,212 Segmentation-ready subset

Note on counts: The paper reports 1,322 images (1,022 train/val + 300 external test) and 10,653 strokes over the complete collection. This packaged, segmentation-ready subset contains 1,082 train/val images and 130 external-test images. Some raw/reference material (raw instances and label source files) is hosted on the GitHub repository under instances/ and labels/.

All images are 400 Γ— 400 PNGs.

Repository Layout

To keep the repo efficient (thousands of small PNGs are packed into a few archives), the image/mask files are shipped as ZIP archives, while metadata is left as plain browsable files:

.
β”œβ”€β”€ README.md                     # This dataset card
β”œβ”€β”€ LICENSE                       # MIT License
β”œβ”€β”€ train_val_images.zip          # images/<id>.png            (1,082 files, 400x400)
β”œβ”€β”€ train_val_masks.zip           # masks/<id>/{1..6}.png       (1,082 folders x 6 masks)
β”œβ”€β”€ train_val_info.csv            # prior-knowledge vector, 1 row per train/val image
β”œβ”€β”€ external_test_images.zip      # images/<id>.png            (130 files)
β”œβ”€β”€ external_test_info.csv        # prior-knowledge vector for external test
└── splits/
    β”œβ”€β”€ train.txt                 # 944 ids
    β”œβ”€β”€ val.txt                   # 98 ids
    β”œβ”€β”€ test.txt                  # 40 ids (internal held-out)
    └── train_test.txt            # 10 ids (small smoke-test subset)

After extraction, each archive expands to an images/ or masks/ directory:

train_val_images.zip   ->  images/<id>.png
train_val_masks.zip    ->  masks/<id>/1.png ... 6.png
external_test_images.zip -> images/<id>.png

Image ↔ mask correspondence

  • An image images/<id>.png (from train_val_images.zip) corresponds to the mask folder masks/<id>/ (from train_val_masks.zip).
  • Each mask folder holds 6 binary PNGs (1.png … 6.png), one per stroke class. During training these are thresholded (> 150 β†’ 1) and stacked into a multi-channel label tensor, so overlapping/intersecting strokes are preserved as independent channels rather than a single argmax label map.
  • IDs, images, and masks are 1:1 aligned β€” every one of the 1,082 images has both an image file and a 6-mask folder (verified: 0 orphans on either side).

*_info.csv β€” prior-knowledge vector

Each info.csv has one row per image, comma-separated, no header:

<id>,v1,v2,v3,v4,v5,v6,v7
  • id β€” image identifier (matches images/<id>.png and masks/<id>/).
  • v1…v7 β€” integer prior-knowledge / stroke-statistic values used by the model as a Prior Knowledge Vector to guide segmentation. Observed value ranges in this release: v1 ∈ [0,26], v2 ∈ [0,4], v3 ∈ [0,10], v4 ∈ [0,6], v5 ∈ [0,5], v6 ∈ [0,1], v7 ∈ [0,3]. external_test_info.csv follows the same format.

Splits

The splits/*.txt files list image IDs (one per line) for reproducing the reference train/val/test partition used in the Stroke-Seg paper:

  • train.txt β€” 944 ids
  • val.txt β€” 98 ids
  • test.txt β€” 40 ids (internal held-out)
  • train_test.txt β€” 10 ids (small smoke-test subset)

The external-test subset is a separate generalization benchmark (different character styles / handwriting) and is not covered by these split files.

Usage

Download and extract the archives, then load images + multi-label masks with Pillow/NumPy:

import os, csv, zipfile, numpy as np
from PIL import Image
from huggingface_hub import hf_hub_download

REPO = "Rvosuke/BCSS"

def fetch_and_extract(filename, dest="."):
    path = hf_hub_download(REPO, filename, repo_type="dataset")
    with zipfile.ZipFile(path) as z:
        z.extractall(dest)

# download archives once
fetch_and_extract("train_val_images.zip")   # -> ./images/<id>.png
fetch_and_extract("train_val_masks.zip")    # -> ./masks/<id>/{1..6}.png
info_path = hf_hub_download(REPO, "train_val_info.csv", repo_type="dataset")
split_path = hf_hub_download(REPO, "splits/train.txt", repo_type="dataset")

# read prior-knowledge vectors
info = {}
with open(info_path, errors="ignore") as f:
    for row in csv.reader(f):
        info[row[0]] = list(map(int, row[1:]))

def load_sample(img_id, size=(400, 400)):
    img = np.array(Image.open(f"images/{img_id}.png").convert("RGB").resize(size))
    mask_dir = f"masks/{img_id}"
    channels = []
    for fn in sorted(os.listdir(mask_dir)):                 # 1.png .. 6.png
        m = Image.open(os.path.join(mask_dir, fn)).convert("L").resize(size)
        channels.append((np.array(m) > 150).astype(np.uint8))
    label = np.stack(channels, axis=0)                      # (6, H, W) multi-label
    return img, label, info[img_id]

ids = [l.strip() for l in open(split_path) if l.strip()]
img, label, prior = load_sample(ids[0])
print(img.shape, label.shape, prior)   # (400,400,3) (6,400,400) [...]

Applications

BCSS can be used to train and evaluate models for brush-calligraphy stroke segmentation. It offers a rich variety of Chinese character styles and a dedicated external test set for measuring generalization across writing styles. The reference framework, Stroke-Seg, is built on DeepLab v3 and introduces a Prior Knowledge Vector, a multi-label output strategy for intersecting strokes, and a boundary-aware loss (BDLoss).

Data Sources & Composition (per paper)

  • Training/Validation (1,022 in paper): images from the E3C dataset.
  • External Testing (300 in paper):
    • 90 E3C images with character types unseen in train/val;
    • 113 handwritten images from the CCSE-W dataset;
    • 97 images of various Chinese character styles (regular printed and brush calligraphy forms, e.g. Clerical Script).

License

Released under the MIT License for research purposes. See LICENSE.

Citation

If you use this dataset, code, or methods, please cite:

@article{gong2024stroke,
  title={Stroke-Seg: A Deep Learning-Based Framework for Chinese Stroke Segmentation},
  author={Gong, Xinyu and Bai, Zeyang and Nie, Haitao and Xie, Bin},
  journal={IET Image Processing},
  volume={18},
  number={13},
  pages={4341--4355},
  year={2024},
  publisher={Wiley Online Library},
  doi={10.1049/ipr2.13255}
}

References

  1. Sun, M., et al. (2023). SRAFE: Siamese Regression Aesthetic Fusion Evaluation for Chinese Calligraphic Copy. CAAI Transactions on Intelligent Technology, 8(3), 1077–1086.
  2. Liu, L., Lin, K., Huang, S., Li, Z., Li, C., Cao, Y., & Zhou, Q. (2022). Instance Segmentation for Chinese Character Stroke Extraction: Datasets and Benchmarks. arXiv:2210.13826.
  3. Long, J., Shelhamer, E., & Darrell, T. (2015). Fully Convolutional Networks for Semantic Segmentation. CVPR, 3431–3440.
  4. Chen, L. C., Papandreou, G., Schroff, F., & Adam, H. (2017). Rethinking Atrous Convolution for Semantic Image Segmentation. arXiv:1706.05587.

Contact

For inquiries about the dataset, please contact:


Related resources β€” Dataset: github.com/Rvosuke/BCSS Β· Paper: IET Image Processing