PrefBench / README.md
wenyii's picture
Upload folder using huggingface_hub
1795deb verified
We provide two prompt sources (`diffusiondb` and `coco`) and two metadata formats (`json` and `pkl`).
Image files are stored in the corresponding `diffusiondb/` and `coco/` folders.
| Path | Description |
|------|-------------|
| `coco/` | image files (e.g., `coco/...png`) |
| `diffusiondb/` | image files (e.g., `diffusiondb/...png`) |
| `json/coco.json` | One JSON object per user (COCO split) |
| `json/diffusiondb.json` | One JSON object per user (DiffusionDB split) |
| `pkl/coco.pkl` | PKL grouping used by PrefDisc-style trainers (see below) |
| `pkl/diffusiondb.pkl` | Same for DiffusionDB |
## Images
Extract image files with:
```
cat coco.tar.part-* | tar -xf - -C coco
cat diffusiondb.tar.part-* | tar -xf - -C diffusiondb
```
## JSON
Each JSON file is a list of per-user records.
Each record is a dictionary with the following fields:
- **`image_file`**: path to the **target** image (training reconstruction target), e.g. `coco/0000102215_0000066902.png`.
- **`text`**: caption for the target image.
- **`negative_img`**: list of paths to **dispreferred** reference images.
- **`positive_img`**: list of paths to **preferred** reference images.
- **`prompt_list`**: list of prompts for the reference images.
For each record, `negative_img`, `positive_img`, and `prompt_list` are index-aligned and have the same length.
Example (abbreviated):
```json
{
"id": "0",
"image_file": "diffusiondb/18869_0000001.png",
"text": "pink, blue, despair personified, artwork",
"negative_img": ["diffusiondb/18863_0036541.png", "..."],
"positive_img": ["diffusiondb/18863_0000001.png", "..."],
"prompt_list": ["...", "..."]
}
```
## PKL
Each PKL file is a dict keyed by user.
Each value is a **list** that stores one user's reference pairs and attributes.
This PKL format contains the same preference information as JSON:
reference pairs (`negative_img`, `positive_img`, `prompt_list`) plus
`negative_attributes` and `positive_attributes`.
- For each reference pair: **`(negative_filename, positive_filename, prompt)`**
(filenames can be joined with `coco/` or `diffusiondb/` under the dataset root).
- The **last** element of the list is **`[negative_attributes, positive_attributes]`**.
In short, the value format is:
`[(neg_img1, pos_img1, prompt1), (neg_img2, pos_img2, prompt2), ..., [neg_attr, pos_attr]]`.
Example:
```python
import pickle
with open("diffusiondb.pkl", "rb") as f:
data = pickle.load(f)
sample_user = data[3]
print(sample_user)
```
Output:
```text
[("145191_0004851.png", "145191_0000007.png", "a human chest burster coming out of a xenomorph"), ..., ["Academic Art ...", "Abstract Expressionism ..."]]
```