--- 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 This dataset card mirrors and is cross-linked with the project's GitHub repository: **[github.com/Rvosuke/BCSS](https://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](https://github.com/Rvosuke/BCSS) 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/.png (1,082 files, 400x400) โ”œโ”€โ”€ train_val_masks.zip # masks//{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/.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/.png train_val_masks.zip -> masks//1.png ... 6.png external_test_images.zip -> images/.png ``` ### Image โ†” mask correspondence - An image `images/.png` (from `train_val_images.zip`) corresponds to the mask folder `masks//` (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: ``` ,v1,v2,v3,v4,v5,v6,v7 ``` - **`id`** โ€” image identifier (matches `images/.png` and `masks//`). - **`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`: ```python 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/.png fetch_and_extract("train_val_masks.zip") # -> ./masks//{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: ```bibtex @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: - zeyangbai.rvo@gmail.com - xiebin@csu.edu.cn --- *Related resources โ€” Dataset: [github.com/Rvosuke/BCSS](https://github.com/Rvosuke/BCSS) ยท Paper: [IET Image Processing](https://doi.org/10.1049/ipr2.13255)*