Blue2Giant commited on
Commit
7894832
·
verified ·
1 Parent(s): 5e5cadd

Update dataset README usage guide

Browse files
Files changed (1) hide show
  1. README.md +186 -203
README.md CHANGED
@@ -1,258 +1,241 @@
1
- ---
2
- pretty_name: "FreeStyle Dataset: cref/sref LoRA Triplets"
3
- task_categories:
4
- - image-to-image
5
- tags:
6
- - image-to-image
7
- - style-reference
8
- - content-reference
9
- - lora
10
- - triplet
11
- - prompt-provenance
12
- size_categories:
13
- - 100K<n<1M
14
- ---
15
 
16
- # FreeStyle Dataset: cref/sref LoRA Triplets
17
 
18
- This repository contains a file-based image triplet dataset for content-reference (`cref`) and style-reference (`sref`) training/evaluation. The exported payload is under [`cref_sref/`](./cref_sref/).
19
 
20
- Each row in a `triplets.csv` file represents one training sequence with three images:
 
 
 
 
21
 
22
- - **content**: image used as the content reference (`cref_0`)
23
- - **style**: image used as the style reference (`sref_0`)
24
- - **target**: image for the combined content+style result
25
 
26
- The images are deduplicated within each source/role. A single image file can be reused by multiple triplet rows.
27
 
28
- ## Quick Start
29
-
30
- Install lightweight dependencies:
31
-
32
- ```bash
33
- pip install huggingface_hub pandas pillow
34
  ```
35
 
36
- Download and inspect the metadata for one source without downloading all images:
37
 
38
- ```python
39
- from huggingface_hub import hf_hub_download
40
- import pandas as pd
41
-
42
- repo_id = "Blue2Giant/FreeStyle_Dataset"
43
- source = "qwen" # one of: qwen, flux, illustrious
44
-
45
- triplets_csv = hf_hub_download(
46
- repo_id=repo_id,
47
- repo_type="dataset",
48
- filename=f"cref_sref/{source}/triplets.csv",
49
- )
50
- triplets = pd.read_csv(triplets_csv)
51
-
52
- print(len(triplets))
53
- print(triplets[[
54
- "sequence_id",
55
- "content_image_path",
56
- "style_image_path",
57
- "target_image_path",
58
- "content_generation_prompt",
59
- "style_generation_prompt",
60
- "target_generation_prompt",
61
- ]].head())
62
- ```
63
 
64
- Download the three images for one triplet:
65
 
66
- ```python
67
- from huggingface_hub import hf_hub_download
68
- from PIL import Image
69
- import pandas as pd
70
-
71
- repo_id = "Blue2Giant/FreeStyle_Dataset"
72
- source = "qwen"
73
-
74
- triplets_csv = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"cref_sref/{source}/triplets.csv")
75
- triplets = pd.read_csv(triplets_csv)
76
- row = triplets.iloc[0]
77
-
78
- paths = {}
79
- for role in ["content", "style", "target"]:
80
- rel = row[f"{role}_image_path"] # relative to cref_sref/<source>/
81
- paths[role] = hf_hub_download(
82
- repo_id=repo_id,
83
- repo_type="dataset",
84
- filename=f"cref_sref/{source}/{rel}",
85
- )
86
-
87
- images = {role: Image.open(path).convert("RGB") for role, path in paths.items()}
88
- print(row["sequence_id"], images["content"].size, images["style"].size, images["target"].size)
89
  ```
90
 
91
- ## Recommended Download Patterns
92
 
93
- This is a large file-tree dataset. Prefer selective downloads rather than cloning/downloading the entire repository at once.
 
 
 
 
94
 
95
- Download all CSV/JSON/README metadata, but no images:
96
 
97
  ```python
98
- from huggingface_hub import snapshot_download
99
-
100
- snapshot_dir = snapshot_download(
101
- repo_id="Blue2Giant/FreeStyle_Dataset",
102
- repo_type="dataset",
103
- allow_patterns=[
104
- "README.md",
105
- "cref_sref/README.md",
106
- "cref_sref/*/README.md",
107
- "cref_sref/*/summary.json",
108
- "cref_sref/*/*.csv",
109
- ],
110
- )
111
- print(snapshot_dir)
 
 
 
 
 
 
 
 
 
112
  ```
113
 
114
- Download one complete source, including images:
115
 
116
  ```python
117
- from huggingface_hub import snapshot_download
118
-
119
- source = "qwen" # qwen is the smallest; flux and illustrious are much larger
120
- snapshot_dir = snapshot_download(
121
- repo_id="Blue2Giant/FreeStyle_Dataset",
122
- repo_type="dataset",
123
- allow_patterns=["README.md", "cref_sref/README.md", f"cref_sref/{source}/**"],
124
- )
125
- print(snapshot_dir)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  ```
127
 
128
- If you need the full dataset, use `snapshot_download(repo_type="dataset")`, but expect many files.
129
-
130
  ## Repository Layout
131
 
 
 
132
  ```text
133
  <repo-root>/
134
- README.md # this guide
135
  cref_sref/
136
- README.md # payload-level guide
137
  HF_UPLOAD_CHECKLIST.md
138
  qwen/
139
- README.md
140
- summary.json
141
- triplets.csv
142
- content_images.csv
143
- style_images.csv
144
- target_images.csv
145
- images/
146
- content/...
147
- style/...
148
- target/...
149
  flux/
150
- ... same layout ...
151
  illustrious/
152
- ... same layout ...
153
  ```
154
 
155
- Public upload notes:
156
-
157
- - `_state/` export-resume folders are omitted.
158
- - `logs/` are omitted.
159
- - Paths stored in `triplets.csv` are relative to the source directory, e.g. relative to `cref_sref/qwen/`.
160
-
161
- ## Sources and Counts
162
 
163
- | Source | Triplet rows | Unique content images | Unique style images | Unique target images |
164
- |---|---:|---:|---:|---:|
165
- | `qwen` | 33,582 | 90 | 424 | 5,162 |
166
- | `flux` | 273,682 | 482 | 13,037 | 129,237 |
167
- | `illustrious` | 172,589 | 8,045 | 1,581 | 65,952 |
168
- | **Total** | **479,853** | **8,617** | **15,042** | **200,351** |
169
-
170
- Total exported image files across source/role directories: **224,010**.
171
-
172
- ## File Semantics
173
-
174
- ### `triplets.csv`
175
-
176
- Use `triplets.csv` as the main training/evaluation index. Important columns include:
177
-
178
- - `sequence_id`: unique sequence id
179
- - `base_model`: one of `qwen`, `flux`, `illustrious`
180
- - `pair_key`: pair identifier
181
- - `content_model_id`, `style_model_id`
182
- - `content_image_path`, `style_image_path`, `target_image_path`
183
- - `content_original_path`, `style_original_path`, `target_original_path`
184
- - `content_match_status`, `style_match_status`, `target_match_status`
185
- - `content_prompt_status`, `style_prompt_status`, `target_prompt_status`
186
- - `content_generation_prompt`, `style_generation_prompt`, `target_generation_prompt`
187
- - `vault_texts_json`
188
-
189
- For model training, the most common fields are the three `*_image_path` columns and, when available, the three `*_generation_prompt` columns.
190
-
191
- ### `content_images.csv`, `style_images.csv`, `target_images.csv`
192
-
193
- These files are deduplicated image-level metadata tables. Important columns include:
194
-
195
- - `exported_image_path`: image path relative to the source directory
196
- - `original_path`: best-effort recovered original generation image path
197
- - `match_status`: original-path matching status
198
- - `prompt_status`: prompt recovery status
199
- - `generation_prompt`
200
- - `base_prompt`
201
- - `sequence_count`: number of triplet rows that reuse this image
202
- - `sequence_ids_json`: triplet ids that reuse this image
203
-
204
- Join keys:
205
 
206
- - `triplets.csv.content_image_path` -> `content_images.csv.exported_image_path`
207
- - `triplets.csv.style_image_path` -> `style_images.csv.exported_image_path`
208
- - `triplets.csv.target_image_path` -> `target_images.csv.exported_image_path`
209
 
210
- Example join:
211
 
212
- ```python
213
- from huggingface_hub import hf_hub_download
214
- import pandas as pd
 
 
 
 
 
 
 
215
 
216
- repo_id = "Blue2Giant/FreeStyle_Dataset"
217
- source = "qwen"
218
 
219
- triplets = pd.read_csv(hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"cref_sref/{source}/triplets.csv"))
220
- content_meta = pd.read_csv(hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"cref_sref/{source}/content_images.csv"))
221
- content_meta = content_meta.set_index("exported_image_path")
222
 
223
- row = triplets.iloc[0]
224
- print(content_meta.loc[row["content_image_path"]])
 
 
225
  ```
226
 
227
- ## Match and Prompt Status Values
228
-
229
- `match_status` describes whether the exporter could map an exported vault image back to an original candidate image:
230
-
231
- - `matched`: exact visual-key match found in the candidate pool
232
- - `unmatched`: candidate pool existed, but no exact unique match was found
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  - `ambiguous`: more than one candidate matched the same visual key
234
  - `no_candidates`: no candidate pool was available for that lookup
235
 
236
- `prompt_status` describes whether generation prompt metadata was recovered:
237
 
238
- - `resolved`: prompt metadata was recovered
239
  - `unmatched_original`: original image path was not matched
240
  - `missing_prompt_payload`: prompt sidecar JSON was missing
241
  - `missing_prompt_entry`: prompt file existed, but the specific image entry was missing
242
  - `missing_prompt_index`: image filename could not be mapped to a prompt index
243
 
244
- ## Important Notes
245
-
246
- - Exported images are vault training images, not guaranteed to be raw copies of the original one-LoRA or dual-LoRA generation files.
247
- - `original_path` and prompt recovery fields are best-effort provenance fields. Do not assume every row has a resolved prompt.
248
- - Rows with unresolved provenance are intentionally kept rather than forcing incorrect prompt assignments.
249
- - The repository is organized as ordinary files. Use `huggingface_hub`, `pandas`, and `Pillow` for flexible access.
250
 
251
- ## Where to Start
 
 
 
252
 
253
- 1. Choose a source: start with `qwen` for a smaller first pass.
254
- 2. Read `cref_sref/<source>/README.md` and `summary.json`.
255
- 3. Load `cref_sref/<source>/triplets.csv`.
256
- 4. For each row, resolve image paths relative to `cref_sref/<source>/`.
257
- 5. Optionally join to the deduplicated `*_images.csv` metadata tables for provenance and reuse statistics.
258
 
 
 
1
+ # 0426 CRef/SRef LoRA Triplet Dataset
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ This dataset is a normalized export of the LoRA-triplet portion of the 0426 CRef/SRef diffusion training configuration. It contains paired **content reference**, **style reference**, and **target** training images, plus CSV metadata that links each training sample to its images and recovered prompt/provenance information.
4
 
5
+ The export covers three base-model sources:
6
 
7
+ | Source directory | Original source name | Triplets |
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
+ ## Start Here: How To Use The Dataset
 
 
14
 
15
+ Pick one source directory under `cref_sref/` according to the base model you want to train or evaluate:
16
 
17
+ ```text
18
+ cref_sref/qwen/
19
+ cref_sref/flux/
20
+ cref_sref/illustrious/
 
 
21
  ```
22
 
23
+ For ordinary use, start from that source's `triplets.csv`. Each row is one training example:
24
 
25
+ - `content_image_path`: content/reference image, corresponding to `cref_0`
26
+ - `style_image_path`: style/reference image, corresponding to `sref_0`
27
+ - `target_image_path`: target image combining the content and style
28
+ - `*_generation_prompt`: recovered generation prompt when available
29
+ - `vault_texts_json`: original text fields from the vault sequence
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
+ All image paths in the CSV are **relative to the source directory**. For example, if a row in `cref_sref/qwen/triplets.csv` contains:
32
 
33
+ ```text
34
+ content_image_path = images/content/xxx.png
35
+ style_image_path = images/style/yyy.png
36
+ target_image_path = images/target/zzz.png
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  ```
38
 
39
+ then the corresponding files are:
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
+ ### Minimal Python Example
48
 
49
  ```python
50
+ import csv
51
+ from pathlib import Path
52
+ from PIL import Image
53
+
54
+ source_dir = Path("/path/to/dataset/cref_sref/qwen") # or flux / illustrious
55
+
56
+ with open(source_dir / "triplets.csv", newline="", encoding="utf-8") as f:
57
+ row = next(csv.DictReader(f))
58
+
59
+ 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
+ sample = {
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
  ```python
78
+ import csv
79
+ from pathlib import Path
80
+ from PIL import Image
81
+ from torch.utils.data import Dataset
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
  ## Repository Layout
129
 
130
+ The Hugging Face repository is organized as:
131
+
132
  ```text
133
  <repo-root>/
134
+ README.md
135
  cref_sref/
136
+ README.md
137
  HF_UPLOAD_CHECKLIST.md
138
  qwen/
 
 
 
 
 
 
 
 
 
 
139
  flux/
 
140
  illustrious/
 
141
  ```
142
 
143
+ Each source directory has the same structure:
 
 
 
 
 
 
144
 
145
+ ```text
146
+ cref_sref/<source>/
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
+ For most users, the important files are `triplets.csv` and the `images/` directory. The `*_images.csv` files are useful when you need deduplicated image-level metadata.
 
 
161
 
162
+ ## Files And Relationships
163
 
164
+ | File | Level | Use it for |
165
+ | --- | --- | --- |
166
+ | `triplets.csv` | sequence/triplet | Main training/evaluation table: one row per content-style-target example. |
167
+ | `content_images.csv` | deduplicated image | Metadata for unique content images. |
168
+ | `style_images.csv` | deduplicated image | Metadata for unique style images. |
169
+ | `target_images.csv` | deduplicated image | Metadata for unique target images. |
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
+ The images are deduplicated. The same image file can be reused by multiple triplet rows.
 
176
 
177
+ To join triplet-level rows to image-level metadata:
 
 
178
 
179
+ ```text
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
+ ## Key `triplets.csv` Columns
186
+
187
+ | Column | Meaning |
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
+ ## Provenance Status Fields
214
+
215
+ `original_path` and prompt fields are best-effort provenance metadata. Some rows intentionally remain unresolved rather than assigning an incorrect original path or prompt.
216
+
217
+ `match_status` values:
218
+
219
+ - `matched`: exact visual-key match found in the original candidate pool
220
+ - `unmatched`: candidate pool exists, but no exact unique match was found
221
  - `ambiguous`: more than one candidate matched the same visual key
222
  - `no_candidates`: no candidate pool was available for that lookup
223
 
224
+ `prompt_status` values:
225
 
226
+ - `resolved`: generation prompt metadata was recovered
227
  - `unmatched_original`: original image path was not matched
228
  - `missing_prompt_payload`: prompt sidecar JSON was missing
229
  - `missing_prompt_entry`: prompt file existed, but the specific image entry was missing
230
  - `missing_prompt_index`: image filename could not be mapped to a prompt index
231
 
232
+ ## Notes
 
 
 
 
 
233
 
234
+ - Exported images are vault training images, not raw copies of the original one-LoRA or dual-LoRA generation PNG files.
235
+ - Use `triplets.csv` for training/evaluation samples; use `*_images.csv` only when you need image-level deduplication or provenance analysis.
236
+ - `_state/` is internal export/resume state and is not required for normal dataset consumption.
237
+ - `logs/`, if present in a working export, is internal and should not be treated as dataset payload.
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/`.