|
--- |
|
task_categories: |
|
- text-to-image |
|
language: |
|
- en |
|
tags: |
|
- not-for-all-audiences |
|
size_categories: |
|
- n<1K |
|
--- |
|
# Bang Dream 数据集 / Bang Dream Dataset |
|
|
|
本数据集包含截止至 2025 年 1 月 31 日的《BanG Dream!》企划中全部 51 名角色的相关图片及元数据。 |
|
/ |
|
This dataset contains images and metadata for all 51 characters in the "BanG Dream!" project as of January 31, 2025. |
|
|
|
## 1. 数据集概述 / Dataset Overview |
|
|
|
数据集主要包含以下几个部分: |
|
/ |
|
The dataset mainly consists of the following parts: |
|
|
|
* **角色信息 (bangdream_character_info.json)** :记录每个角色的详细信息,包括 ID、版权、核心标签、性别倾向、图片数量等。 |
|
/ |
|
**Character Information (bangdream_character_info.json)**: Records detailed information for each character, including ID, copyright, core tags, gender distribution, number of images, etc. |
|
* **标签pid映射 (tag_mapping_full.json)**: 记录每个标签对应的图片 PID(图片唯一标识符)。 |
|
/ |
|
**Tag Mapping (tag_mapping_full.json)**: Records the PID (unique image identifier) of images corresponding to each tag. |
|
* **角色图片**:存储在 `char_datasets/{hash_prefix}/{file_name}` 目录下,包含不同类型的图片和数据文件。 |
|
/ |
|
**Character Images**: Stored in the `char_datasets/{hash_prefix}/{file_name}` directory, containing different types of images and data files. |
|
|
|
**数据来源:** 本数据集的图片及标签信息均来自 [Danbooru](https://danbooru.donmai.us/) 网站。 |
|
/ |
|
**Data Sources:** The images and tag information in this dataset are from the [Danbooru](https://danbooru.donmai.us/) website. |
|
|
|
## 2. 角色信息 (bangdream_character_info.json) / Character Information (bangdream_character_info.json) |
|
|
|
`bangdream_character_info.json` 文件以 JSON 格式存储了每个角色的详细信息。示例如下: |
|
/ |
|
The `bangdream_character_info.json` file stores detailed information for each character in JSON format. An example is as follows: |
|
|
|
```json |
|
[ |
|
{ |
|
"_id": "mortis_(bang_dream!)", |
|
"copyright": { |
|
"bang_dream!": 1.0, |
|
"bang_dream!_it's_mygo!!!!!": 1.0 |
|
}, |
|
"core_tag_update_time": { |
|
"$date": "2025-02-21T05:21:42.583Z" |
|
}, |
|
"core_tags": [ |
|
"long_hair", |
|
"green_hair", |
|
"hat", |
|
"yellow_eyes", |
|
"red_hat", |
|
"beret", |
|
"ascot", |
|
"capelet" |
|
], |
|
"gender": { |
|
"1girl": 0.3268633540372671 |
|
}, |
|
"id": 2258229, |
|
"post_count": 1288 |
|
} |
|
] |
|
``` |
|
|
|
每个字段的含义如下: |
|
/ |
|
The meaning of each field is as follows: |
|
|
|
* `_id`: 角色的唯一标识符, 对应 Danbooru 上的角色 tag。 |
|
/ |
|
`_id`: Unique identifier for the character, corresponding to the character tag on Danbooru. |
|
* `copyright`: 版权信息,表示该角色在不同作品中的权重。 |
|
/ |
|
`copyright`: Copyright information, indicating the weight of the character in different works. |
|
* `core_tag_update_time`: 核心标签的更新时间。 |
|
/ |
|
`core_tag_update_time`: The update time of the core tags. |
|
* `core_tags`: 角色的核心标签列表。**这些标签直接对应 Danbooru 上的角色 tag。** |
|
/ |
|
`core_tags`: List of core tags for the character. **These tags directly correspond to the character tags on Danbooru.** |
|
* `gender`: 性别倾向。 |
|
/ |
|
`gender`: Gender distribution. |
|
* `id`: 角色 ID。 |
|
/ |
|
`id`: Character ID. |
|
* `post_count`: 包含该角色的图片数量。 |
|
/ |
|
`post_count`: The number of images containing the character. |
|
|
|
## 3. 标签映射 (tag_mapping_full) / Tag Mapping (tag_mapping_full) |
|
|
|
`tag_mapping_full` 文件记录了每个标签对应的图片在Danbooru的PID。 |
|
/ |
|
The `tag_mapping_full` file records the Danbooru PID of the images corresponding to each tag. |
|
|
|
## 4. 图片存储结构 / Image Storage Structure |
|
|
|
角色图片存储在 `char_datasets` 目录下,按照以下结构组织: |
|
/ |
|
Character images are stored in the `char_datasets` directory, organized as follows: |
|
|
|
``` |
|
char_datasets/ |
|
├── {hash_prefix}/ |
|
│ ├── {file_name}.tar |
|
│ ├── {file_name}.npy |
|
│ └── {file_name}.json |
|
``` |
|
|
|
* `{hash_prefix}`:根据角色名计算的哈希前缀。计算方法:将角色名(UTF-8 编码)进行 SHA256 哈希,取结果的前两位。 |
|
/ |
|
`{hash_prefix}`: Hash prefix calculated from the character name. Calculation method: SHA256 hash the character name (UTF-8 encoded), and take the first two characters of the result. |
|
* `{file_name}`:经过处理后的角色名。 |
|
/ |
|
`{file_name}`: The processed character name. |
|
|
|
### 4.1 文件类型 / File Types |
|
|
|
每个角色目录下包含三种类型的文件: |
|
/ |
|
Each character directory contains three types of files: |
|
|
|
* **{file_name}.tar**: 包含角色图片的压缩包。 |
|
* `train/1_char/`: 原始图片 (**WebP 格式**)。 |
|
* `train/1_stage/`: 上半身和头像的碎片图 (**WebP 格式**)。 |
|
|
|
/ |
|
**{file_name}.tar**: Archive containing character images. |
|
* `train/1_char/`: Original images (**WebP format**). |
|
* `train/1_stage/`: Fragment images of the upper body and head (**WebP format**). |
|
* **{file_name}.npy**: 包含 CCIP 特征数据, 用于ccip模型识别 model name:ccip-caformer-24-randaug-pruned 。 |
|
/ |
|
**{file_name}.npy**: Contains CCIP feature data, used for CCIP model recognition model name:ccip-caformer-24-randaug-pruned . |
|
* **{file_name}.json**: 包含 `.tar` 文件的元数据信息。 |
|
/ |
|
**{file_name}.json**: Contains metadata information for the `.tar` file. |
|
|
|
## 5. 文件名处理 / Filename Processing |
|
|
|
角色名会经过以下步骤处理成文件名: |
|
/ |
|
The character name is processed into a file name through the following steps: |
|
|
|
1. **规范化**:移除非 ASCII 字符。使用 `unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore').decode('ASCII')` 实现。 |
|
/ |
|
**Normalization**: Remove non-ASCII characters. Implemented using `unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore').decode('ASCII')`. |
|
2. **替换非法字符**:将 Windows 文件名中不允许的字符(`<>:"/\\|?*`)替换为下划线。使用 `re.sub(r'[<>:"/\\|?*]', '_', filename)` 实现。 |
|
/ |
|
**Replace Illegal Characters**: Replace characters not allowed in Windows filenames (`<>:"/\\|?*`) with underscores. Implemented using `re.sub(r'[<>:"/\\|?*]', '_', filename)`. |
|
3. **去除前后空格**:使用 `filename.strip()`。 |
|
/ |
|
**Remove Leading/Trailing Spaces**: Use `filename.strip()`. |
|
4. **空文件名处理**:如果文件名为空,则使用默认名称 `"untitled"`。 |
|
/ |
|
**Empty Filename Handling**: If the filename is empty, use the default name `"untitled"`. |
|
5. **长度截断**:如果文件名长度超过 255 个字符,则截断至 255 个字符。 |
|
/ |
|
**Length Truncation**: If the filename length exceeds 255 characters, truncate it to 255 characters. |
|
|
|
Python 代码如下: |
|
/ |
|
The Python code is as follows: |
|
|
|
```python |
|
import unicodedata |
|
import re |
|
|
|
def sanitize_filename(filename): |
|
# 去除非 ASCII 字符 |
|
# Remove non-ASCII characters |
|
filename = unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore').decode('ASCII') |
|
|
|
# 替换不允许的字符为下划线 |
|
# Replace disallowed characters with underscores |
|
filename = re.sub(r'[<>:"/\\|?*]', '_', filename) |
|
|
|
# 去除前后空格 |
|
# Remove leading and trailing whitespace |
|
filename = filename.strip() |
|
|
|
# 确保文件名不为空,如果为空则使用默认名称 |
|
# Ensure the filename is not empty; use a default name if it is |
|
if not filename: |
|
filename = "untitled" |
|
|
|
# 截断文件名长度(如果需要) |
|
# Truncate the filename length (if necessary) |
|
max_length = 255 # 大多数文件系统的最大文件名长度 |
|
# Maximum filename length for most file systems |
|
if len(filename) > max_length: |
|
filename = filename[:max_length] |
|
return filename |
|
|
|
``` |