Datasets:
File size: 9,657 Bytes
5f280e7 aa0481c bdc4c6f 5f280e7 aa0481c 19824be aa0481c 19824be | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | ---
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) ποΈ
[](https://github.com/Rvosuke/BCSS)
[](https://doi.org/10.1049/ipr2.13255)
[](https://opensource.org/licenses/MIT)
> 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/<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`:
```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/<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:
```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)*
|