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
- clustering
|
| 9 |
+
tags:
|
| 10 |
+
- anime
|
| 11 |
+
- keyframes
|
| 12 |
+
- images
|
| 13 |
+
- clip
|
| 14 |
+
- aesthetic-scoring
|
| 15 |
+
- k-means
|
| 16 |
+
- parquet
|
| 17 |
+
- jsonl
|
| 18 |
+
pretty_name: Anime Keyframes
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# Anime Keyframes
|
| 22 |
+
|
| 23 |
+
## Overview
|
| 24 |
+
|
| 25 |
+
This dataset contains anime keyframe images and associated metadata for
|
| 26 |
+
visual exploration, image retrieval, clustering, aesthetic analysis, and
|
| 27 |
+
multimodal machine-learning tasks.
|
| 28 |
+
|
| 29 |
+
The repository contains three main data components:
|
| 30 |
+
|
| 31 |
+
- `images/`: image files.
|
| 32 |
+
- `jsonl/`: JSONL metadata shards. Each JSONL record contains metadata and
|
| 33 |
+
an image reference.
|
| 34 |
+
- `captions.parquet`: a tabular index containing metadata and processing
|
| 35 |
+
results.
|
| 36 |
+
|
| 37 |
+
The JSONL records may refer to images using relative paths such as:
|
| 38 |
+
|
| 39 |
+
`../images/00000000_f8597d6a05.jpg`
|
| 40 |
+
|
| 41 |
+
**Important:** These are repository-relative references, not necessarily
|
| 42 |
+
valid local filesystem paths. Loading JSONL directly with
|
| 43 |
+
`datasets.load_dataset("json", ...)` and casting the image column to
|
| 44 |
+
`datasets.Image` can fail because the image decoder may try to open the
|
| 45 |
+
relative path on the local filesystem.
|
| 46 |
+
|
| 47 |
+
Use the explicit Hugging Face Hub download and path-resolution procedure
|
| 48 |
+
in this card to load images reliably.
|
| 49 |
+
|
| 50 |
+
## Repository layout
|
| 51 |
+
|
| 52 |
+
```text
|
| 53 |
+
anime-keyframes/
|
| 54 |
+
├── README.md
|
| 55 |
+
├── captions.parquet
|
| 56 |
+
├── images/
|
| 57 |
+
│ ├── 00000000_f8597d6a05.jpg
|
| 58 |
+
│ └── ...
|
| 59 |
+
└── jsonl/
|
| 60 |
+
├── shard_00000.jsonl
|
| 61 |
+
└── ...
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
The exact number and names of JSONL shards and images may vary.
|
| 65 |
+
|
| 66 |
+
## Data schema
|
| 67 |
+
|
| 68 |
+
### `captions.parquet`
|
| 69 |
+
|
| 70 |
+
Each row represents one image/keyframe.
|
| 71 |
+
|
| 72 |
+
| Column | Description |
|
| 73 |
+
|---|---|
|
| 74 |
+
| `idx` | Dataset-local image or record index. |
|
| 75 |
+
| `prompt` | Prompt text, if available. May be empty. |
|
| 76 |
+
| `tags` | Tag text, if available. May be empty. |
|
| 77 |
+
| `author` | Dataset author/source attribution field. |
|
| 78 |
+
| `json_file` | JSONL filename containing the corresponding serialized record. |
|
| 79 |
+
| `byte_offset` | Zero-based byte offset of the record in the JSONL file. |
|
| 80 |
+
| `byte_length` | Number of bytes occupied by the record. |
|
| 81 |
+
| `instruction` | Instruction metadata, if present. |
|
| 82 |
+
| `thinking_response` | Thinking/reasoning metadata, if present. |
|
| 83 |
+
| `written_response` | Written response or description, if present. |
|
| 84 |
+
| `addendum` | Additional metadata or notes, if present. |
|
| 85 |
+
| `tag_prediction` | Serialized tagger prediction data. May be `[]` if tagging was skipped. |
|
| 86 |
+
| `group_number` | K-means cluster assignment based on CLIP image embeddings. |
|
| 87 |
+
| `clip_aesthetic_score` | Predicted aesthetic score based on a CLIP ViT-B/32 embedding and a learned linear predictor. |
|
| 88 |
+
|
| 89 |
+
Some text fields may contain empty strings. Empty values should be treated as
|
| 90 |
+
missing or ungenerated annotations, not as negative labels.
|
| 91 |
+
|
| 92 |
+
### JSONL records
|
| 93 |
+
|
| 94 |
+
The JSONL shards contain serialized metadata records. An image reference
|
| 95 |
+
inside a JSONL record may be a relative path, for example:
|
| 96 |
+
|
| 97 |
+
`../images/00000000_f8597d6a05.jpg`
|
| 98 |
+
|
| 99 |
+
Resolve this path against the repository layout, not against the JSONL
|
| 100 |
+
file's local directory. In the loading example below, the leading `../`
|
| 101 |
+
is removed and the remaining `images/...` path is downloaded from the
|
| 102 |
+
dataset repository.
|
| 103 |
+
|
| 104 |
+
### CLIP clustering
|
| 105 |
+
|
| 106 |
+
`group_number` is an unsupervised K-means cluster identifier derived from
|
| 107 |
+
OpenCLIP ViT-B/32 embeddings using the `laion400m_e32` pretrained weights.
|
| 108 |
+
|
| 109 |
+
Cluster IDs are categorical identifiers, not semantic class labels.
|
| 110 |
+
A cluster number does not inherently represent a character, series, style,
|
| 111 |
+
or scene type.
|
| 112 |
+
|
| 113 |
+
### Aesthetic score
|
| 114 |
+
|
| 115 |
+
`clip_aesthetic_score` is a model prediction calculated by applying a
|
| 116 |
+
learned linear aesthetic predictor to a CLIP ViT-B/32 image embedding,
|
| 117 |
+
applying sigmoid, and multiplying the result by 10.
|
| 118 |
+
|
| 119 |
+
The score is approximately on a 0–10 scale. It is not an objective measure
|
| 120 |
+
of image quality or a human rating. It should be treated as a model-derived
|
| 121 |
+
ranking feature.
|
| 122 |
+
|
| 123 |
+
### Tagging fields
|
| 124 |
+
|
| 125 |
+
The WD tagger may have been skipped during dataset preparation. In that
|
| 126 |
+
case, `tags` and `prompt` may be empty, and `tag_prediction` may contain
|
| 127 |
+
`[]`.
|
| 128 |
+
|
| 129 |
+
This does not mean that an image contains no recognizable objects,
|
| 130 |
+
characters, or visual concepts. It means that those annotations were not
|
| 131 |
+
generated in this dataset build.
|
| 132 |
+
|
| 133 |
+
## Loading the dataset
|
| 134 |
+
|
| 135 |
+
Install the required packages:
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
pip install -U huggingface_hub datasets pandas pyarrow pillow
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
### Recommended method: download metadata and resolve image paths
|
| 142 |
+
|
| 143 |
+
This method works with JSONL records containing relative image references.
|
| 144 |
+
|
| 145 |
+
```python
|
| 146 |
+
from huggingface_hub import HfApi, hf_hub_download
|
| 147 |
+
from PIL import Image
|
| 148 |
+
from pathlib import Path
|
| 149 |
+
import json
|
| 150 |
+
import io
|
| 151 |
+
|
| 152 |
+
REPO_ID = "codeShare/anime-keyframes"
|
| 153 |
+
|
| 154 |
+
api = HfApi()
|
| 155 |
+
|
| 156 |
+
# List files in the dataset repository.
|
| 157 |
+
repo_files = api.list_repo_files(
|
| 158 |
+
repo_id=REPO_ID,
|
| 159 |
+
repo_type="dataset",
|
| 160 |
+
)
|
| 161 |
+
|
| 162 |
+
# Download all JSONL shards.
|
| 163 |
+
jsonl_files = sorted([
|
| 164 |
+
path for path in repo_files
|
| 165 |
+
if path.endswith(".jsonl")
|
| 166 |
+
])
|
| 167 |
+
|
| 168 |
+
records = []
|
| 169 |
+
|
| 170 |
+
for jsonl_file in jsonl_files:
|
| 171 |
+
local_jsonl = hf_hub_download(
|
| 172 |
+
repo_id=REPO_ID,
|
| 173 |
+
repo_type="dataset",
|
| 174 |
+
filename=jsonl_file,
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
with open(local_jsonl, "r", encoding="utf-8") as f:
|
| 178 |
+
for line in f:
|
| 179 |
+
if line.strip():
|
| 180 |
+
records.append(json.loads(line))
|
| 181 |
+
|
| 182 |
+
print("Records:", len(records))
|
| 183 |
+
print("Example record:", records[0])
|
| 184 |
+
```
|
| 185 |
+
|
| 186 |
+
### Resolve and load an image
|
| 187 |
+
|
| 188 |
+
The image path in a record may be stored as `../images/...`. Convert it
|
| 189 |
+
to a repository path before downloading it.
|
| 190 |
+
|
| 191 |
+
The following helper searches common image-reference fields. If your
|
| 192 |
+
record schema uses a different field, inspect a record and add that
|
| 193 |
+
field name to `IMAGE_KEYS`.
|
| 194 |
+
|
| 195 |
+
```python
|
| 196 |
+
IMAGE_KEYS = [
|
| 197 |
+
"image",
|
| 198 |
+
"image_path",
|
| 199 |
+
"file_name",
|
| 200 |
+
"filename",
|
| 201 |
+
"path",
|
| 202 |
+
]
|
| 203 |
+
|
| 204 |
+
def get_image_reference(record):
|
| 205 |
+
for key in IMAGE_KEYS:
|
| 206 |
+
value = record.get(key)
|
| 207 |
+
|
| 208 |
+
if isinstance(value, str) and value.strip():
|
| 209 |
+
return value
|
| 210 |
+
|
| 211 |
+
# Support datasets where image is stored as a dictionary.
|
| 212 |
+
if isinstance(value, dict):
|
| 213 |
+
for nested_key in ("path", "image", "file_name"):
|
| 214 |
+
nested_value = value.get(nested_key)
|
| 215 |
+
if isinstance(nested_value, str) and nested_value.strip():
|
| 216 |
+
return nested_value
|
| 217 |
+
|
| 218 |
+
raise KeyError(
|
| 219 |
+
"Could not find an image reference. "
|
| 220 |
+
f"Available fields: {list(record.keys())}"
|
| 221 |
+
)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def resolve_repo_image_path(image_reference):
|
| 225 |
+
path = str(image_reference).replace("\\", "/").lstrip("/")
|
| 226 |
+
|
| 227 |
+
while path.startswith("../"):
|
| 228 |
+
path = path[3:]
|
| 229 |
+
|
| 230 |
+
if path.startswith("images/"):
|
| 231 |
+
return path
|
| 232 |
+
|
| 233 |
+
# Reject unexpected paths rather than silently downloading
|
| 234 |
+
# a file from an unrelated repository directory.
|
| 235 |
+
raise ValueError(
|
| 236 |
+
f"Unexpected image reference: {image_reference}"
|
| 237 |
+
)
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def load_record_image(record):
|
| 241 |
+
image_reference = get_image_reference(record)
|
| 242 |
+
repo_image_path = resolve_repo_image_path(image_reference)
|
| 243 |
+
|
| 244 |
+
local_image = hf_hub_download(
|
| 245 |
+
repo_id=REPO_ID,
|
| 246 |
+
repo_type="dataset",
|
| 247 |
+
filename=repo_image_path,
|
| 248 |
+
)
|
| 249 |
+
|
| 250 |
+
return Image.open(local_image).convert("RGB")
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
# Example: load and display the first image.
|
| 254 |
+
image = load_record_image(records[0])
|
| 255 |
+
display(image)
|
| 256 |
+
```
|
| 257 |
+
|
| 258 |
+
### Create a Hugging Face Dataset with decoded images
|
| 259 |
+
|
| 260 |
+
Once the image paths have been resolved, create a dataset using local
|
| 261 |
+
image paths. This avoids the broken relative-path behavior of directly
|
| 262 |
+
casting the original JSONL image references.
|
| 263 |
+
|
| 264 |
+
```python
|
| 265 |
+
from datasets import Dataset, Image as HFImage
|
| 266 |
+
|
| 267 |
+
rows = []
|
| 268 |
+
|
| 269 |
+
for record in records:
|
| 270 |
+
image_reference = get_image_reference(record)
|
| 271 |
+
repo_image_path = resolve_repo_image_path(image_reference)
|
| 272 |
+
|
| 273 |
+
local_image_path = hf_hub_download(
|
| 274 |
+
repo_id=REPO_ID,
|
| 275 |
+
repo_type="dataset",
|
| 276 |
+
filename=repo_image_path,
|
| 277 |
+
)
|
| 278 |
+
|
| 279 |
+
row = dict(record)
|
| 280 |
+
row["image"] = local_image_path
|
| 281 |
+
rows.append(row)
|
| 282 |
+
|
| 283 |
+
dataset = Dataset.from_list(rows)
|
| 284 |
+
dataset = dataset.cast_column("image", HFImage())
|
| 285 |
+
|
| 286 |
+
print(dataset)
|
| 287 |
+
print(dataset[0])
|
| 288 |
+
display(dataset[0]["image"])
|
| 289 |
+
```
|
| 290 |
+
|
| 291 |
+
This approach downloads every referenced image, so it can take time and
|
| 292 |
+
disk space for a large dataset. For exploratory work, download only the
|
| 293 |
+
images needed for the current task.
|
| 294 |
+
|
| 295 |
+
### Load the Parquet metadata table
|
| 296 |
+
|
| 297 |
+
```python
|
| 298 |
+
import pandas as pd
|
| 299 |
+
from huggingface_hub import hf_hub_download
|
| 300 |
+
|
| 301 |
+
parquet_path = hf_hub_download(
|
| 302 |
+
repo_id=REPO_ID,
|
| 303 |
+
repo_type="dataset",
|
| 304 |
+
filename="captions.parquet",
|
| 305 |
+
)
|
| 306 |
+
|
| 307 |
+
df = pd.read_parquet(parquet_path)
|
| 308 |
+
|
| 309 |
+
print(df.shape)
|
| 310 |
+
print(df.dtypes)
|
| 311 |
+
print(df.head())
|
| 312 |
+
```
|
| 313 |
+
|
| 314 |
+
Alternatively, use the Hugging Face Datasets library:
|
| 315 |
+
|
| 316 |
+
```python
|
| 317 |
+
from datasets import load_dataset
|
| 318 |
+
|
| 319 |
+
metadata = load_dataset(
|
| 320 |
+
"parquet",
|
| 321 |
+
data_files={
|
| 322 |
+
"train": f"hf://datasets/{REPO_ID}/captions.parquet"
|
| 323 |
+
},
|
| 324 |
+
split="train",
|
| 325 |
+
)
|
| 326 |
+
|
| 327 |
+
print(metadata)
|
| 328 |
+
print(metadata[0])
|
| 329 |
+
```
|
| 330 |
+
|
| 331 |
+
### Retrieve a JSONL record using the Parquet byte offsets
|
| 332 |
+
|
| 333 |
+
The `json_file`, `byte_offset`, and `byte_length` columns allow a record
|
| 334 |
+
to be retrieved without scanning the entire JSONL shard.
|
| 335 |
+
|
| 336 |
+
Byte offsets must be used with binary file access. They are byte positions,
|
| 337 |
+
not character positions or line numbers.
|
| 338 |
+
|
| 339 |
+
```python
|
| 340 |
+
import json
|
| 341 |
+
from huggingface_hub import hf_hub_download
|
| 342 |
+
|
| 343 |
+
def read_jsonl_record(row):
|
| 344 |
+
local_path = hf_hub_download(
|
| 345 |
+
repo_id=REPO_ID,
|
| 346 |
+
repo_type="dataset",
|
| 347 |
+
filename=row["json_file"],
|
| 348 |
+
)
|
| 349 |
+
|
| 350 |
+
with open(local_path, "rb") as f:
|
| 351 |
+
f.seek(int(row["byte_offset"]))
|
| 352 |
+
raw = f.read(int(row["byte_length"]))
|
| 353 |
+
|
| 354 |
+
return json.loads(raw.decode("utf-8").strip())
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
record = read_jsonl_record(df.iloc[0])
|
| 358 |
+
print(json.dumps(record, indent=2, ensure_ascii=False))
|
| 359 |
+
```
|
| 360 |
+
|
| 361 |
+
The JSONL files and Parquet index must remain paired. If JSONL files are
|
| 362 |
+
rewritten, concatenated, or re-encoded, their byte offsets may become
|
| 363 |
+
invalid. Regenerate the Parquet index whenever the JSONL byte layout changes.
|
| 364 |
+
|
| 365 |
+
## Example analysis tasks
|
| 366 |
+
|
| 367 |
+
### Filter by aesthetic score
|
| 368 |
+
|
| 369 |
+
```python
|
| 370 |
+
high_scoring = df[
|
| 371 |
+
df["clip_aesthetic_score"] >= 7.0
|
| 372 |
+
]
|
| 373 |
+
|
| 374 |
+
print(len(high_scoring))
|
| 375 |
+
```
|
| 376 |
+
|
| 377 |
+
### Rank images by aesthetic score
|
| 378 |
+
|
| 379 |
+
```python
|
| 380 |
+
ranked = df.sort_values(
|
| 381 |
+
"clip_aesthetic_score",
|
| 382 |
+
ascending=False,
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
print(
|
| 386 |
+
ranked[
|
| 387 |
+
["idx", "group_number", "clip_aesthetic_score"]
|
| 388 |
+
].head(20)
|
| 389 |
+
)
|
| 390 |
+
```
|
| 391 |
+
|
| 392 |
+
### Inspect cluster sizes
|
| 393 |
+
|
| 394 |
+
```python
|
| 395 |
+
cluster_counts = (
|
| 396 |
+
df["group_number"]
|
| 397 |
+
.value_counts()
|
| 398 |
+
.sort_index()
|
| 399 |
+
)
|
| 400 |
+
|
| 401 |
+
print(cluster_counts)
|
| 402 |
+
```
|
| 403 |
+
|
| 404 |
+
### Compare aesthetic scores across clusters
|
| 405 |
+
|
| 406 |
+
```python
|
| 407 |
+
cluster_summary = (
|
| 408 |
+
df.groupby("group_number")["clip_aesthetic_score"]
|
| 409 |
+
.agg(["count", "mean", "median", "min", "max"])
|
| 410 |
+
.sort_values("mean", ascending=False)
|
| 411 |
+
)
|
| 412 |
+
|
| 413 |
+
print(cluster_summary)
|
| 414 |
+
```
|
| 415 |
+
|
| 416 |
+
### Sample images from a cluster
|
| 417 |
+
|
| 418 |
+
```python
|
| 419 |
+
cluster_id = 0
|
| 420 |
+
|
| 421 |
+
cluster_rows = df[df["group_number"] == cluster_id]
|
| 422 |
+
sample = cluster_rows.sample(
|
| 423 |
+
n=min(10, len(cluster_rows)),
|
| 424 |
+
random_state=42,
|
| 425 |
+
)
|
| 426 |
+
|
| 427 |
+
for _, row in sample.iterrows():
|
| 428 |
+
record = read_jsonl_record(row)
|
| 429 |
+
image = load_record_image(record)
|
| 430 |
+
|
| 431 |
+
print(
|
| 432 |
+
"Index:", row["idx"],
|
| 433 |
+
"Cluster:", row["group_number"],
|
| 434 |
+
"Aesthetic score:", row["clip_aesthetic_score"],
|
| 435 |
+
)
|
| 436 |
+
display(image)
|
| 437 |
+
```
|
| 438 |
+
|
| 439 |
+
## Guidance for downstream machine-learning tasks
|
| 440 |
+
|
| 441 |
+
- Use `captions.parquet` as the primary table for filtering and statistical
|
| 442 |
+
analysis.
|
| 443 |
+
- Use JSONL records to inspect the full serialized metadata and discover
|
| 444 |
+
image references.
|
| 445 |
+
- Resolve repository-relative image paths before opening images.
|
| 446 |
+
- Use `group_number` as an unsupervised grouping feature, not as a class label.
|
| 447 |
+
- Use `clip_aesthetic_score` as a model-derived score, not as ground truth.
|
| 448 |
+
- Treat empty tag and prompt fields as unavailable annotations.
|
| 449 |
+
- Consider cluster-aware train/validation/test splits when visual similarity
|
| 450 |
+
leakage is a concern.
|
| 451 |
+
- Verify image dimensions, file formats, duplicate images, and metadata
|
| 452 |
+
completeness before training.
|
| 453 |
+
- Record the dataset revision and preprocessing settings for reproducibility.
|
| 454 |
+
- Verify image rights and licensing before redistribution, publication,
|
| 455 |
+
commercial use, or model training.
|
| 456 |
+
|
| 457 |
+
## Limitations
|
| 458 |
+
|
| 459 |
+
This dataset should not be assumed to be balanced across characters,
|
| 460 |
+
series, styles, artists, or scene types.
|
| 461 |
+
|
| 462 |
+
Cluster assignments depend on the embedding model and K-means settings.
|
| 463 |
+
Aesthetic scores may reflect biases in the predictor's training data.
|
| 464 |
+
Optional annotation fields may be empty because an annotation stage was
|
| 465 |
+
not run.
|
| 466 |
+
|
| 467 |
+
Public availability does not automatically grant unrestricted rights to
|
| 468 |
+
redistribute or commercially use the images. Users are responsible for
|
| 469 |
+
checking the applicable rights and restrictions.
|
| 470 |
+
|
| 471 |
+
## Intended uses
|
| 472 |
+
|
| 473 |
+
Potential applications include:
|
| 474 |
+
|
| 475 |
+
- Anime image similarity search.
|
| 476 |
+
- Visual clustering and cluster exploration.
|
| 477 |
+
- Image retrieval and ranking.
|
| 478 |
+
- Aesthetic-score analysis.
|
| 479 |
+
- Image captioning and image understanding.
|
| 480 |
+
- Dataset curation and filtering.
|
| 481 |
+
- Representation learning and multimodal model experiments.
|
| 482 |
+
- Studying visual composition and style.
|
| 483 |
+
|