Blue2Giant commited on
Commit
230ca1b
·
verified ·
1 Parent(s): f3b71a1

Improve cref_sref dataset usage README

Browse files
Files changed (2) hide show
  1. README.md +203 -150
  2. cref_sref/README.md +68 -18
README.md CHANGED
@@ -1,205 +1,258 @@
1
- # 0426 Lora Triplet Dataset
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- This directory contains the normalized export of the lora-triplet portion of:
4
 
5
- - `/data/vgo/xingpeng/new_vgo/Sref_Cref_MiniVGO/configs/data/0426_cref_sref_full_diffusion.yaml`
6
 
7
- It covers three nonzero-weight lora-triplet sources:
8
 
9
- - `cref_sref_qwen_lora_part1`
10
- - `cref_sref_flux_lora_part1`
11
- - `cref_sref_illustrious_lora_part1`
12
 
13
- ## Directory Layout
14
 
15
- For the Hugging Face release, the dataset card stays at repository root and the exported data is placed under `cref_sref/`:
16
 
17
- ```text
18
- <repo-root>/
19
- README.md
20
- cref_sref/
21
- HF_UPLOAD_CHECKLIST.md
22
- README.md
23
- qwen/
24
- flux/
25
- illustrious/
26
  ```
27
 
28
- The working export root may also contain `logs/`. That directory is internal and can be excluded from the Hugging Face upload.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
- Each source subdirectory under `cref_sref/` has the same structure:
31
 
32
- ```text
33
- <source-name>/
34
- README.md
35
- summary.json
36
- triplets.csv
37
- content_images.csv
38
- style_images.csv
39
- target_images.csv
40
- images/
41
- content/...
42
- style/...
43
- target/...
44
- _state/
45
- manifest.json
46
- triplets.jsonl
47
- content_images.jsonl
48
- style_images.jsonl
49
- target_images.jsonl
 
 
 
 
 
50
  ```
51
 
52
- ## What A Triplet Means
53
 
54
- Each triplet row corresponds to one vault training sequence and three training images:
55
 
56
- - `content`: the image used for `cref_0`
57
- - `style`: the image used for `sref_0`
58
- - `target`: the image used for the combined content+style target
59
 
60
- So the key relationship is:
 
61
 
62
- - `triplets.csv` = one row per training sequence
63
- - `content_images.csv` = one row per unique content image
64
- - `style_images.csv` = one row per unique style image
65
- - `target_images.csv` = one row per unique target image
 
 
 
 
 
 
 
 
 
66
 
67
- The images are deduplicated. The same exported image path can appear in many triplet rows.
68
 
69
- ## How To Read The Files
 
70
 
71
- ### 1. `triplets.csv`
 
 
 
 
 
 
 
72
 
73
- Use this file when you want to understand the training example itself.
74
 
75
- Important columns:
76
 
77
- - `sequence_id`: unique id of the vault sequence
78
- - `base_model`: one of `qwen`, `flux`, `illustrious`
79
- - `pair_key`: pair identifier
80
- - `content_model_id`
81
- - `style_model_id`
82
- - `content_image_path`
83
- - `style_image_path`
84
- - `target_image_path`
85
- - `content_original_path`
86
- - `style_original_path`
87
- - `target_original_path`
88
- - `content_match_status`
89
- - `style_match_status`
90
- - `target_match_status`
91
- - `content_prompt_status`
92
- - `style_prompt_status`
93
- - `target_prompt_status`
94
- - `content_generation_prompt`
95
- - `style_generation_prompt`
96
- - `target_generation_prompt`
97
- - `vault_texts_json`
 
98
 
99
- ### 2. `content_images.csv` / `style_images.csv` / `target_images.csv`
100
 
101
- Use these files when you want image-level metadata.
 
 
102
 
103
- Important columns:
104
 
105
- - `exported_image_path`: relative path under the source directory
106
- - `original_path`: recovered original generation image path when matched
107
- - `match_status`: whether original-path matching succeeded
108
- - `prompt_status`: whether the original generation prompt was recovered
109
- - `generation_prompt`
110
- - `base_prompt`
111
- - `sequence_count`: how many triplets reuse this exported image
112
- - `sequence_ids_json`: which triplets reuse this image
113
 
114
- ## How To View One Triplet
115
 
116
- ### Method 1: inspect one row from `triplets.csv`
117
 
118
- ```bash
119
- python3 - <<'PY'
120
- import csv
121
- path = '/path/to/repo/cref_sref/qwen/triplets.csv'
122
- with open(path, 'r', encoding='utf-8', newline='') as fh:
123
- row = next(csv.DictReader(fh))
124
- for key in [
125
- 'sequence_id',
126
- 'pair_key',
127
- 'content_image_path',
128
- 'style_image_path',
129
- 'target_image_path',
130
- 'content_match_status',
131
- 'style_match_status',
132
- 'target_match_status',
133
- 'content_generation_prompt',
134
- 'style_generation_prompt',
135
- 'target_generation_prompt',
136
- ]:
137
- print(f'{key}: {row[key]}')
138
- PY
139
- ```
140
 
141
- ### Method 2: load the three images for a given sequence
142
 
143
- ```bash
144
- python3 - <<'PY'
145
- import csv
146
- from pathlib import Path
147
-
148
- base = Path('/path/to/repo/cref_sref/qwen')
149
- with open(base / 'triplets.csv', 'r', encoding='utf-8', newline='') as fh:
150
- row = next(csv.DictReader(fh))
151
-
152
- print('sequence_id:', row['sequence_id'])
153
- print('content image:', base / row['content_image_path'])
154
- print('style image:', base / row['style_image_path'])
155
- print('target image:', base / row['target_image_path'])
156
- PY
157
- ```
158
 
159
- ### Method 3: join a triplet row to image-level metadata
 
 
 
 
 
 
 
 
 
160
 
161
- Join:
162
 
163
  - `triplets.csv.content_image_path` -> `content_images.csv.exported_image_path`
164
  - `triplets.csv.style_image_path` -> `style_images.csv.exported_image_path`
165
  - `triplets.csv.target_image_path` -> `target_images.csv.exported_image_path`
166
 
167
- This lets you answer:
168
 
169
- - Which triplets reuse the same image?
170
- - What is the recovered original path?
171
- - Was the original prompt recovered?
172
 
173
- ## How To Interpret Match And Prompt Status
 
174
 
175
- ### `match_status`
 
 
176
 
177
- - `matched`: exact visual-key match found in the original candidate pool
178
- - `unmatched`: candidate pool exists, but no exact unique match was found
 
 
 
 
 
 
 
 
179
  - `ambiguous`: more than one candidate matched the same visual key
180
  - `no_candidates`: no candidate pool was available for that lookup
181
 
182
- ### `prompt_status`
183
 
184
- - `resolved`: generation prompt metadata was recovered
185
  - `unmatched_original`: original image path was not matched
186
- - `missing_prompt_payload`: prompt sidecar json was missing
187
  - `missing_prompt_entry`: prompt file existed, but the specific image entry was missing
188
  - `missing_prompt_index`: image filename could not be mapped to a prompt index
189
 
190
- ## Important Semantics
191
-
192
- - Exported images are vault training images, not raw copies of original one-lora or dual-lora PNG files.
193
- - `original_path` and prompt recovery fields are best-effort provenance fields.
194
- - Some rows intentionally remain unmatched rather than risk incorrect prompt assignment.
195
- - `_state/` is internal resume state used during export; it is not required for ordinary dataset consumption.
196
 
197
- ## Source-Level Summary
 
 
 
198
 
199
- Final exported sequence counts:
200
 
201
- - `qwen`: `33,582`
202
- - `flux`: `273,682`
203
- - `illustrious`: `172,589`
 
 
204
 
205
- For detailed per-source match counts, see each source's `summary.json`.
 
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
 
 
cref_sref/README.md CHANGED
@@ -1,25 +1,75 @@
1
- # cref_sref
2
 
3
- This directory is the Hugging Face payload for the 0426 lora-triplet release.
4
 
5
- Contents:
6
- - `qwen/`
7
- - `flux/`
8
- - `illustrious/`
9
 
10
- Each source directory includes:
11
- - `README.md`
12
- - `summary.json`
13
- - `triplets.csv`
14
- - `content_images.csv`
15
- - `style_images.csv`
16
- - `target_images.csv`
17
- - `images/`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- Notes:
20
  - `triplets.csv` is sequence-level.
21
  - `*_images.csv` files are deduplicated image-level metadata.
22
- - `_state/` is omitted from the public upload.
23
- - `logs/` are omitted from the public upload.
24
 
25
- Start with the source-level `README.md` and `triplets.csv`.
 
1
+ # `cref_sref` Payload Guide
2
 
3
+ This folder contains the content-reference/style-reference LoRA triplet payload for the FreeStyle dataset.
4
 
5
+ Start from the root [`README.md`](../README.md) for full usage examples. This file summarizes the payload layout.
 
 
 
6
 
7
+ ## Sources
8
+
9
+ | Source | Triplet rows | Unique content images | Unique style images | Unique target images |
10
+ |---|---:|---:|---:|---:|
11
+ | `qwen` | 33,582 | 90 | 424 | 5,162 |
12
+ | `flux` | 273,682 | 482 | 13,037 | 129,237 |
13
+ | `illustrious` | 172,589 | 8,045 | 1,581 | 65,952 |
14
+
15
+ ## Layout
16
+
17
+ Each source directory has the same structure:
18
+
19
+ ```text
20
+ <source>/
21
+ README.md
22
+ summary.json
23
+ triplets.csv
24
+ content_images.csv
25
+ style_images.csv
26
+ target_images.csv
27
+ images/
28
+ content/...
29
+ style/...
30
+ target/...
31
+ ```
32
+
33
+ `_state/` and `logs/` are intentionally not included in the public upload.
34
+
35
+ ## How to Use
36
+
37
+ For a source such as `qwen`:
38
+
39
+ 1. Read `qwen/triplets.csv`; it is the sequence-level index.
40
+ 2. For each row, use:
41
+ - `content_image_path`
42
+ - `style_image_path`
43
+ - `target_image_path`
44
+ 3. Resolve those paths relative to `cref_sref/qwen/`.
45
+ 4. Use `content_images.csv`, `style_images.csv`, and `target_images.csv` only when you need image-level metadata, reuse counts, original-path provenance, or prompt recovery details.
46
+
47
+ Minimal Python example:
48
+
49
+ ```python
50
+ from huggingface_hub import hf_hub_download
51
+ from PIL import Image
52
+ import pandas as pd
53
+
54
+ repo_id = "Blue2Giant/FreeStyle_Dataset"
55
+ source = "qwen"
56
+
57
+ triplets = pd.read_csv(hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"cref_sref/{source}/triplets.csv"))
58
+ row = triplets.iloc[0]
59
+
60
+ content_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"cref_sref/{source}/{row['content_image_path']}")
61
+ style_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"cref_sref/{source}/{row['style_image_path']}")
62
+ target_path = hf_hub_download(repo_id=repo_id, repo_type="dataset", filename=f"cref_sref/{source}/{row['target_image_path']}")
63
+
64
+ content = Image.open(content_path).convert("RGB")
65
+ style = Image.open(style_path).convert("RGB")
66
+ target = Image.open(target_path).convert("RGB")
67
+ ```
68
+
69
+ ## Notes
70
 
 
71
  - `triplets.csv` is sequence-level.
72
  - `*_images.csv` files are deduplicated image-level metadata.
73
+ - The same image can be reused by many triplets; check `sequence_count` in the image metadata tables.
74
+ - Prompt/provenance fields are best effort. Rows with unresolved provenance are intentionally preserved.
75