Datasets:
Update concise root README with training prompt fields
Browse files
README.md
CHANGED
|
@@ -1,57 +1,61 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
| --- | --- | ---: |
|
| 9 |
-
| `qwen/` | `cref_sref_qwen_lora_part1` | 33,582 |
|
| 10 |
-
| `flux/` | `cref_sref_flux_lora_part1` | 273,682 |
|
| 11 |
-
| `illustrious/` | `cref_sref_illustrious_lora_part1` | 172,589 |
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
``
|
| 18 |
-
cref_sref/qwen/
|
| 19 |
-
cref_sref/flux/
|
| 20 |
-
cref_sref/illustrious/
|
| 21 |
-
```
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
|
| 33 |
```text
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
```
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
```text
|
| 42 |
-
cref_sref/qwen/images/content/xxx.png
|
| 43 |
-
cref_sref/qwen/images/style/yyy.png
|
| 44 |
-
cref_sref/qwen/images/target/zzz.png
|
| 45 |
-
```
|
| 46 |
|
| 47 |
-
|
| 48 |
|
| 49 |
```python
|
| 50 |
import csv
|
| 51 |
from pathlib import Path
|
| 52 |
from PIL import Image
|
| 53 |
|
| 54 |
-
source_dir = Path("/path/to/
|
| 55 |
|
| 56 |
with open(source_dir / "triplets.csv", newline="", encoding="utf-8") as f:
|
| 57 |
row = next(csv.DictReader(f))
|
|
@@ -60,182 +64,114 @@ content = Image.open(source_dir / row["content_image_path"]).convert("RGB")
|
|
| 60 |
style = Image.open(source_dir / row["style_image_path"]).convert("RGB")
|
| 61 |
target = Image.open(source_dir / row["target_image_path"]).convert("RGB")
|
| 62 |
|
| 63 |
-
|
| 64 |
-
"sequence_id": row["sequence_id"],
|
| 65 |
-
"base_model": row["base_model"],
|
| 66 |
-
"content": content,
|
| 67 |
-
"style": style,
|
| 68 |
-
"target": target,
|
| 69 |
-
"content_prompt": row.get("content_generation_prompt", ""),
|
| 70 |
-
"style_prompt": row.get("style_generation_prompt", ""),
|
| 71 |
-
"target_prompt": row.get("target_generation_prompt", ""),
|
| 72 |
-
}
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
### Minimal PyTorch Dataset Wrapper
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
class CrefSrefTriplets(Dataset):
|
| 84 |
-
def __init__(self, dataset_root, source="qwen", transform=None):
|
| 85 |
-
root = Path(dataset_root)
|
| 86 |
-
# Accept the repo root, the cref_sref directory, or a source directory.
|
| 87 |
-
if (root / "triplets.csv").exists():
|
| 88 |
-
self.source_dir = root
|
| 89 |
-
elif (root / source / "triplets.csv").exists():
|
| 90 |
-
self.source_dir = root / source
|
| 91 |
-
else:
|
| 92 |
-
self.source_dir = root / "cref_sref" / source
|
| 93 |
-
|
| 94 |
-
if not (self.source_dir / "triplets.csv").exists():
|
| 95 |
-
raise FileNotFoundError(f"Could not find triplets.csv under {self.source_dir}")
|
| 96 |
-
|
| 97 |
-
self.transform = transform
|
| 98 |
-
|
| 99 |
-
with open(self.source_dir / "triplets.csv", newline="", encoding="utf-8") as f:
|
| 100 |
-
self.rows = list(csv.DictReader(f))
|
| 101 |
-
|
| 102 |
-
def __len__(self):
|
| 103 |
-
return len(self.rows)
|
| 104 |
-
|
| 105 |
-
def _load_image(self, rel_path):
|
| 106 |
-
image = Image.open(self.source_dir / rel_path).convert("RGB")
|
| 107 |
-
return self.transform(image) if self.transform else image
|
| 108 |
-
|
| 109 |
-
def __getitem__(self, idx):
|
| 110 |
-
row = self.rows[idx]
|
| 111 |
-
return {
|
| 112 |
-
"sequence_id": row["sequence_id"],
|
| 113 |
-
"base_model": row["base_model"],
|
| 114 |
-
"content_image": self._load_image(row["content_image_path"]),
|
| 115 |
-
"style_image": self._load_image(row["style_image_path"]),
|
| 116 |
-
"target_image": self._load_image(row["target_image_path"]),
|
| 117 |
-
"content_prompt": row.get("content_generation_prompt", ""),
|
| 118 |
-
"style_prompt": row.get("style_generation_prompt", ""),
|
| 119 |
-
"target_prompt": row.get("target_generation_prompt", ""),
|
| 120 |
-
"metadata": row,
|
| 121 |
-
}
|
| 122 |
-
|
| 123 |
-
# Example:
|
| 124 |
-
# ds = CrefSrefTriplets("/path/to/dataset", source="flux")
|
| 125 |
-
# item = ds[0]
|
| 126 |
```
|
| 127 |
|
| 128 |
-
##
|
| 129 |
|
| 130 |
-
The
|
| 131 |
|
| 132 |
```text
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
README.md
|
| 137 |
-
HF_UPLOAD_CHECKLIST.md
|
| 138 |
-
qwen/
|
| 139 |
-
flux/
|
| 140 |
-
illustrious/
|
| 141 |
```
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
```text
|
| 146 |
-
|
| 147 |
-
README.md
|
| 148 |
-
summary.json
|
| 149 |
-
triplets.csv
|
| 150 |
-
content_images.csv
|
| 151 |
-
style_images.csv
|
| 152 |
-
target_images.csv
|
| 153 |
-
images/
|
| 154 |
-
content/...
|
| 155 |
-
style/...
|
| 156 |
-
target/...
|
| 157 |
-
_state/ # optional internal export/resume state
|
| 158 |
```
|
| 159 |
|
| 160 |
-
|
| 161 |
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
|
| 165 |
-
| --- | --- |
|
| 166 |
-
| `
|
| 167 |
-
| `
|
| 168 |
-
| `
|
| 169 |
-
| `
|
| 170 |
-
| `summary.json` | source summary | Counts and match/prompt recovery statistics. |
|
| 171 |
-
| `images/content/` | files | Exported content reference images. |
|
| 172 |
-
| `images/style/` | files | Exported style reference images. |
|
| 173 |
-
| `images/target/` | files | Exported target images. |
|
| 174 |
|
| 175 |
-
|
| 176 |
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
-
|
| 180 |
-
triplets.csv.content_image_path -> content_images.csv.exported_image_path
|
| 181 |
-
triplets.csv.style_image_path -> style_images.csv.exported_image_path
|
| 182 |
-
triplets.csv.target_image_path -> target_images.csv.exported_image_path
|
| 183 |
-
```
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
| 188 |
-
| --- | --- |
|
| 189 |
-
| `sequence_id` | Unique id of the vault training sequence. |
|
| 190 |
-
| `base_model` | One of `qwen`, `flux`, or `illustrious`. |
|
| 191 |
-
| `pair_key` | Pair/group identifier from the export. |
|
| 192 |
-
| `content_model_id`, `style_model_id` | LoRA/model identifiers associated with the content and style sides. |
|
| 193 |
-
| `content_image_path`, `style_image_path`, `target_image_path` | Relative paths to the three exported training images. |
|
| 194 |
-
| `content_original_path`, `style_original_path`, `target_original_path` | Best-effort matched original generation image paths. |
|
| 195 |
-
| `content_match_status`, `style_match_status`, `target_match_status` | Whether original-image matching succeeded. |
|
| 196 |
-
| `content_prompt_status`, `style_prompt_status`, `target_prompt_status` | Whether prompt metadata was recovered. |
|
| 197 |
-
| `content_generation_prompt`, `style_generation_prompt`, `target_generation_prompt` | Recovered prompts when available. |
|
| 198 |
-
| `vault_texts_json` | Original text metadata from the vault sequence, encoded as JSON. |
|
| 199 |
-
|
| 200 |
-
## Key `*_images.csv` Columns
|
| 201 |
-
|
| 202 |
-
| Column | Meaning |
|
| 203 |
-
| --- | --- |
|
| 204 |
-
| `exported_image_path` | Relative image path under the source directory. |
|
| 205 |
-
| `original_path` | Best-effort recovered original generation image path. |
|
| 206 |
-
| `match_status` | Original-path match status. |
|
| 207 |
-
| `prompt_status` | Prompt recovery status. |
|
| 208 |
-
| `generation_prompt` | Recovered generation prompt when available. |
|
| 209 |
-
| `base_prompt` | Recovered base prompt when available. |
|
| 210 |
-
| `sequence_count` | Number of triplets that reuse this image. |
|
| 211 |
-
| `sequence_ids_json` | JSON list of triplet sequence ids using this image. |
|
| 212 |
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
-
`
|
| 216 |
|
| 217 |
-
`
|
| 218 |
|
| 219 |
-
|
| 220 |
-
-
|
| 221 |
-
-
|
| 222 |
-
-
|
|
|
|
| 223 |
|
| 224 |
-
|
| 225 |
|
| 226 |
-
|
| 227 |
-
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
## Notes
|
| 233 |
|
| 234 |
-
-
|
| 235 |
-
-
|
| 236 |
-
- `_state/` is internal export/resume state and is not
|
| 237 |
-
-
|
| 238 |
-
|
| 239 |
-
## Download
|
| 240 |
-
|
| 241 |
-
Download or clone the Hugging Face dataset repository using your usual workflow. The examples above assume the downloaded repository root is `/path/to/dataset` and the data lives under `/path/to/dataset/cref_sref/`.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
pretty_name: 0426 CRef/SRef LoRA Triplet Dataset
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
task_categories:
|
| 7 |
+
- image-to-image
|
| 8 |
+
---
|
| 9 |
|
| 10 |
+
# 0426 CRef/SRef LoRA Triplet Dataset
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
This dataset contains CRef/SRef LoRA triplets exported from the 0426 diffusion training data. Each training example has three images:
|
| 13 |
|
| 14 |
+
- **content**: content reference image, used as `cref_0`
|
| 15 |
+
- **style**: style reference image, used as `sref_0`
|
| 16 |
+
- **target**: image generated from the combined content + style condition
|
| 17 |
|
| 18 |
+
Use `triplets.csv` as the main entry point. Image-level CSV files are provided only for deduplicated metadata and provenance lookup.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
## Sources
|
| 21 |
|
| 22 |
+
| Directory | Base model | Original source | Triplets |
|
| 23 |
+
| --- | --- | --- | ---: |
|
| 24 |
+
| `cref_sref/qwen/` | `qwen` | `cref_sref_qwen_lora_part1` | 33,582 |
|
| 25 |
+
| `cref_sref/flux/` | `flux` | `cref_sref_flux_lora_part1` | 273,682 |
|
| 26 |
+
| `cref_sref/illustrious/` | `illustrious` | `cref_sref_illustrious_lora_part1` | 172,589 |
|
| 27 |
|
| 28 |
+
## Layout
|
| 29 |
|
| 30 |
```text
|
| 31 |
+
<repo-root>/
|
| 32 |
+
README.md
|
| 33 |
+
cref_sref/
|
| 34 |
+
README.md
|
| 35 |
+
qwen/
|
| 36 |
+
triplets.csv
|
| 37 |
+
content_images.csv
|
| 38 |
+
style_images.csv
|
| 39 |
+
target_images.csv
|
| 40 |
+
images/content/...
|
| 41 |
+
images/style/...
|
| 42 |
+
images/target/...
|
| 43 |
+
flux/
|
| 44 |
+
... same structure ...
|
| 45 |
+
illustrious/
|
| 46 |
+
... same structure ...
|
| 47 |
```
|
| 48 |
|
| 49 |
+
## How To Use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
Pick one source directory and read its `triplets.csv`:
|
| 52 |
|
| 53 |
```python
|
| 54 |
import csv
|
| 55 |
from pathlib import Path
|
| 56 |
from PIL import Image
|
| 57 |
|
| 58 |
+
source_dir = Path("/path/to/FreeStyle_Dataset/cref_sref/qwen") # qwen / flux / illustrious
|
| 59 |
|
| 60 |
with open(source_dir / "triplets.csv", newline="", encoding="utf-8") as f:
|
| 61 |
row = next(csv.DictReader(f))
|
|
|
|
| 64 |
style = Image.open(source_dir / row["style_image_path"]).convert("RGB")
|
| 65 |
target = Image.open(source_dir / row["target_image_path"]).convert("RGB")
|
| 66 |
|
| 67 |
+
print(row["sequence_id"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
+
# One training-compatible text pair. The original training samples one of several
|
| 70 |
+
# instruction/caption choices; see the next section.
|
| 71 |
+
instruction = row["vault_primary_instruction_en_123"]
|
| 72 |
+
target_caption = row["vault_captions_scene_3_en"]
|
| 73 |
+
print(instruction)
|
| 74 |
+
print(target_caption)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
```
|
| 76 |
|
| 77 |
+
## Which Prompt Fields Are Used For Training?
|
| 78 |
|
| 79 |
+
The 0426 training config uses the three lora-triplet sources:
|
| 80 |
|
| 81 |
```text
|
| 82 |
+
cref_sref_qwen_lora_part1
|
| 83 |
+
cref_sref_flux_lora_part1
|
| 84 |
+
cref_sref_illustrious_lora_part1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
```
|
| 86 |
|
| 87 |
+
In the training loader, a sample is not represented by a single prompt string. Each training choice is:
|
| 88 |
|
| 89 |
```text
|
| 90 |
+
<cref_0 image> <sref_0 image> <instruction text> <target caption text> <target image>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
```
|
| 92 |
|
| 93 |
+
Only the final `target` image has `require_loss=True`; the two text fields are conditioning text.
|
| 94 |
|
| 95 |
+
For these lora-triplet sources, the training DB provides 8 text choices per sequence. Each choice uses exactly one instruction field plus one target-caption field:
|
| 96 |
|
| 97 |
+
| Instruction field in this CSV | Vault text index |
|
| 98 |
+
| --- | --- |
|
| 99 |
+
| `vault_primary_instruction_en_123` | `primary_instruction_en_123` |
|
| 100 |
+
| `vault_primary_instruction_cn_123` | `primary_instruction_cn_123` |
|
| 101 |
+
| `vault_sample_instruction_en_123` | `sample_instruction_en_123` |
|
| 102 |
+
| `vault_sample_instruction_cn_123` | `sample_instruction_cn_123` |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
+
paired with one of:
|
| 105 |
|
| 106 |
+
| Target-caption field in this CSV | Vault text index |
|
| 107 |
+
| --- | --- |
|
| 108 |
+
| `vault_captions_scene_3_en` | `captions/scene_3_en` |
|
| 109 |
+
| `vault_captions_scene_3` | `captions/scene_3` |
|
| 110 |
|
| 111 |
+
So, to reproduce the training text conditioning, use one of these pairs, for example:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
+
```python
|
| 114 |
+
instruction = row["vault_primary_instruction_en_123"]
|
| 115 |
+
target_caption = row["vault_captions_scene_3_en"]
|
| 116 |
+
texts = [instruction, target_caption]
|
| 117 |
+
```
|
| 118 |
|
| 119 |
+
or sample uniformly from the 8 combinations:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
+
```python
|
| 122 |
+
import random
|
| 123 |
+
|
| 124 |
+
instruction_key = random.choice([
|
| 125 |
+
"vault_primary_instruction_en_123",
|
| 126 |
+
"vault_primary_instruction_cn_123",
|
| 127 |
+
"vault_sample_instruction_en_123",
|
| 128 |
+
"vault_sample_instruction_cn_123",
|
| 129 |
+
])
|
| 130 |
+
caption_key = random.choice([
|
| 131 |
+
"vault_captions_scene_3_en",
|
| 132 |
+
"vault_captions_scene_3",
|
| 133 |
+
])
|
| 134 |
+
|
| 135 |
+
texts = [row[instruction_key], row[caption_key]]
|
| 136 |
+
```
|
| 137 |
|
| 138 |
+
The columns `content_generation_prompt`, `style_generation_prompt`, and `target_generation_prompt` are provenance fields recovered from the original image-generation pipeline. They are useful for analysis, but they are **not** the primary text fields used by the 0426 VGO training loader.
|
| 139 |
|
| 140 |
+
All image paths in `triplets.csv` are **relative to the source directory**. For example, in `cref_sref/qwen/triplets.csv`:
|
| 141 |
|
| 142 |
+
```text
|
| 143 |
+
images/content/xxx.png -> cref_sref/qwen/images/content/xxx.png
|
| 144 |
+
images/style/yyy.png -> cref_sref/qwen/images/style/yyy.png
|
| 145 |
+
images/target/zzz.png -> cref_sref/qwen/images/target/zzz.png
|
| 146 |
+
```
|
| 147 |
|
| 148 |
+
## Main Files
|
| 149 |
|
| 150 |
+
| File | Meaning |
|
| 151 |
+
| --- | --- |
|
| 152 |
+
| `triplets.csv` | One row per training example. This is the file most users should start from. |
|
| 153 |
+
| `content_images.csv` | Deduplicated metadata for unique content images. |
|
| 154 |
+
| `style_images.csv` | Deduplicated metadata for unique style images. |
|
| 155 |
+
| `target_images.csv` | Deduplicated metadata for unique target images. |
|
| 156 |
+
| `summary.json` | Per-source counts and match/prompt recovery statistics. |
|
| 157 |
+
|
| 158 |
+
Important `triplets.csv` columns:
|
| 159 |
+
|
| 160 |
+
- `sequence_id`
|
| 161 |
+
- `base_model`
|
| 162 |
+
- `content_image_path`, `style_image_path`, `target_image_path`
|
| 163 |
+
- `vault_primary_instruction_en_123`, `vault_primary_instruction_cn_123`
|
| 164 |
+
- `vault_sample_instruction_en_123`, `vault_sample_instruction_cn_123`
|
| 165 |
+
- `vault_captions_scene_3_en`, `vault_captions_scene_3`
|
| 166 |
+
- `vault_texts_json`
|
| 167 |
+
- `content_generation_prompt`, `style_generation_prompt`, `target_generation_prompt` provenance fields
|
| 168 |
+
- `content_original_path`, `style_original_path`, `target_original_path` provenance fields
|
| 169 |
+
- `content_match_status`, `style_match_status`, `target_match_status`
|
| 170 |
+
- `content_prompt_status`, `style_prompt_status`, `target_prompt_status`
|
| 171 |
|
| 172 |
## Notes
|
| 173 |
|
| 174 |
+
- Images are deduplicated; the same image file may appear in multiple triplet rows.
|
| 175 |
+
- `original_path` and prompt fields are best-effort provenance metadata and may be unresolved for some rows.
|
| 176 |
+
- `_state/`, if present, is internal export/resume state and is not needed for normal dataset use.
|
| 177 |
+
- For detailed column definitions and provenance status values, see `cref_sref/README.md`.
|
|
|
|
|
|
|
|
|
|
|
|