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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FlowGuard Dataset
|
| 2 |
+

|
| 3 |
+
|
| 4 |
+
## 📦 Overview
|
| 5 |
+
|
| 6 |
+
The **FlowGuard Dataset** is designed to support the training and evaluation of the *FlowGuard* framework, with a focus on **safety-aware image generation and auditing**.
|
| 7 |
+
|
| 8 |
+
To ensure scalability and efficient storage, the dataset is:
|
| 9 |
+
|
| 10 |
+
- organized **by model architecture**
|
| 11 |
+
- packed into **size-balanced tar shards**
|
| 12 |
+
- filtered to retain only essential supervision signals
|
| 13 |
+
|
| 14 |
+
We include generations from **9 different diffusion / generative architectures**, enabling diverse and robust evaluation.
|
| 15 |
+
|
| 16 |
---
|
| 17 |
+
## 🚀 Loading and Usage
|
| 18 |
+
|
| 19 |
+
The dataset is stored on Hugging Face as **Parquet shards** organized by split, model, and label:
|
| 20 |
+
|
| 21 |
+
```text
|
| 22 |
+
train/{model}/{label}/*.parquet
|
| 23 |
+
test/{model}/{label}/*.parquet
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
Each row contains one image sample with metadata such as model name, split, safety label, case ID, step type, and step index.
|
| 27 |
+
|
| 28 |
+
### Load the full dataset
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from datasets import load_dataset
|
| 32 |
+
|
| 33 |
+
dataset = load_dataset(
|
| 34 |
+
"parquet",
|
| 35 |
+
data_files={
|
| 36 |
+
"train": "hf://datasets/YeQingWen/FlowGuard-Dataset/train/*/*/*.parquet",
|
| 37 |
+
"test": "hf://datasets/YeQingWen/FlowGuard-Dataset/test/*/*/*.parquet",
|
| 38 |
+
}
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
print(dataset)
|
| 42 |
+
print(dataset["train"][0])
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Load a specific model
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
from datasets import load_dataset
|
| 49 |
+
|
| 50 |
+
dataset = load_dataset(
|
| 51 |
+
"parquet",
|
| 52 |
+
data_files={
|
| 53 |
+
"train": "hf://datasets/YeQingWen/FlowGuard-Dataset/train/flux1/*/*.parquet",
|
| 54 |
+
"test": "hf://datasets/YeQingWen/FlowGuard-Dataset/test/flux1/*/*.parquet",
|
| 55 |
+
}
|
| 56 |
+
)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
### Load a specific model and label
|
| 60 |
+
|
| 61 |
+
```python
|
| 62 |
+
from datasets import load_dataset
|
| 63 |
+
|
| 64 |
+
safe_flux1_train = load_dataset(
|
| 65 |
+
"parquet",
|
| 66 |
+
data_files={
|
| 67 |
+
"train": "hf://datasets/YeQingWen/FlowGuard-Dataset/train/flux1/safe/*.parquet"
|
| 68 |
+
},
|
| 69 |
+
split="train"
|
| 70 |
+
)
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
### Access an image
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
example = dataset["train"][0]
|
| 77 |
+
|
| 78 |
+
image = example["image"]
|
| 79 |
+
label = example["label"]
|
| 80 |
+
model = example["model"]
|
| 81 |
+
step_type = example["step_type"]
|
| 82 |
+
step_index = example["step_index"]
|
| 83 |
+
|
| 84 |
+
image.show()
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
Each example contains:
|
| 88 |
+
|
| 89 |
+
- `model`: generation architecture
|
| 90 |
+
- `split`: `train` or `test`
|
| 91 |
+
- `label`: `safe` or `unsafe`
|
| 92 |
+
- `case_id`: generation case identifier
|
| 93 |
+
- `step_type`: `linear_step` or `step49`
|
| 94 |
+
- `step_index`: diffusion step index
|
| 95 |
+
- `image`: decoded image object
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
## NSFW Category Distribution
|
| 99 |
+
The NSFW category is shown below:
|
| 100 |
+
|
| 101 |
+

|
| 102 |
+
|
| 103 |
---
|
| 104 |
+
## 📊 Statistics
|
| 105 |
+
|
| 106 |
+
The table below reflects the **full, unbalanced dataset distribution**.
|
| 107 |
+
|
| 108 |
+
> ⚠️ During training, we **subsample to achieve a balanced distribution**.
|
| 109 |
+
> For details, see: https://arxiv.org/abs/2604.07879
|
| 110 |
+
|
| 111 |
+
| Model | Train Safe | Train Unsafe | Train Total | Test Safe | Test Unsafe | Test Total | Overall Total |
|
| 112 |
+
|--------------|-----------|--------------|-------------|-----------|-------------|------------|----------------|
|
| 113 |
+
| flux1 | 2,687 | 1,953 | **4,640** | 200 | 237 | **437** | **5,077** |
|
| 114 |
+
| flux2 | 671 | 2,017 | **2,688** | 227 | 181 | **408** | **3,096** |
|
| 115 |
+
| pixart | 2,725 | 4,246 | **6,971** | 195 | 231 | **426** | **7,397** |
|
| 116 |
+
| Qwen-Image | 2,643 | 2,055 | **4,698** | 196 | 496 | **692** | **5,390** |
|
| 117 |
+
| sd3 | 1,250 | 1,293 | **2,543** | 200 | 191 | **391** | **2,934** |
|
| 118 |
+
| sd3.5 | N/A | N/A | N/A | 391 | 317 | **708** | **708** |
|
| 119 |
+
| sdv1.5 | 2,659 | 3,537 | **6,196** | 199 | 253 | **452** | **6,648** |
|
| 120 |
+
| sdxl | 1,899 | 1,759 | **3,658** | 243 | 282 | **525** | **4,183** |
|
| 121 |
+
| Zimage | 2,676 | 1,910 | **4,586** | 199 | 248 | **447** | **5,033** |
|
| 122 |
+
| **Total** | **17,210**| **18,770** | **35,980** | **2,050** | **2,436** | **4,486** | **40,466** |
|
| 123 |
+
|
| 124 |
+
---
|
| 125 |
+
|
| 126 |
+
## 🛡️ Auditing
|
| 127 |
+
|
| 128 |
+
To ensure dataset quality:
|
| 129 |
+
|
| 130 |
+
- The **training set** is automatically audited using `LlavaGuard-7B`
|
| 131 |
+
- The **test set** is curated under **strict human supervision**
|
| 132 |
+
|
| 133 |
+
This hybrid pipeline ensures both **scalability** and **high-quality evaluation signals**.
|
| 134 |
+
|
| 135 |
+
For implementation details (e.g., prompts and hyperparameters), please refer to:
|
| 136 |
+
|
| 137 |
+
https://arxiv.org/abs/2604.07879
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
## 📌 Notes
|
| 142 |
+
|
| 143 |
+
- Each sample corresponds to a **generation case (subdirectory)**
|
| 144 |
+
- Each case contains:
|
| 145 |
+
- multiple `linear_step` outputs
|
| 146 |
+
- one `final image`
|
| 147 |
+
- `.pt` files are **excluded** to reduce storage overhead
|