Dataset Viewer
Duplicate
The dataset viewer is not available for this split.
Server error while post-processing the rows. Please report the issue.
Error code:   RowsPostProcessingError

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

Cafca Synthetic Face Dataset: WebDataset

Cafca (Buehler et al., SIGGRAPH Asia 2024) is a large-scale synthetic multiview face dataset for avatar reconstruction, novel-view synthesis, face parsing, relighting, camera estimation, and more. This repo repackages it as streamable WebDataset shards for direct use with datasets.load_dataset(..., streaming=True), so there's no manual zip download and unpacking required.

The full Cafca dataset contains 1,500 synthetic subjects, each rendered in 3 environments with 13 expressions from 30 camera views (512x512), for 1.755M images total.

What's in this repo right now

This repo currently hosts the mini dataset: 5 subjects at full fidelity (all 13 expressions x 3 environments x 30 views each). The full 1,500-subject dataset (~1.22TB across 15 chunks) is not uploaded yet.

If the WebDataset format is useful to you, let us know and we'll convert and upload the rest. The conversion pipeline is already built and tested end-to-end on this mini dataset (see Reproducing this conversion below), so scaling it up is mainly a matter of compute time and prioritization:

Quickstart for agents

Working with an AI coding agent (Claude Code, Codex, Pi, or similar) on novel-view synthesis, face parsing, camera pose estimation, FLAME/3D face fitting, or relighting? This repo streams directly via datasets.load_dataset("mcbuehler/cafca-dataset", "views", streaming=True), no zip download or extraction needed, but watch two gotchas that produce silently wrong results if skipped: joining flame_params requires deriving the key as f"{subject}/{expr_env.split('_')[1]}" rather than treating it as a string prefix, and grouping views into scenes with itertools.groupby only works under sequential, single-worker, no-shuffle reads. See the notebook for a runnable end-to-end example.

Why WebDataset, and why three configs

Each Cafca "scene" (one subject, expression, and environment) is a multiview capture: 30 camera images plus per-view masks, segmentation, and landmarks, one fitted mesh for the whole scene, and FLAME parameters shared across all 13 expressions of a subject+environment. That's three genuinely different sample granularities, so this repo ships three WebDataset configs rather than forcing everything into one flat table:

Config Sample key Contents Granularity
views SUBJECT/EXPR_ENV/CAM rgb.png, mask.png, seg.png, cam.json, landmark.npz, env.json one per camera (finest)
scene_mesh SUBJECT/EXPR_ENV mesh.obj, mesh.mtl, mesh.jpg one per scene (30 views share it)
flame_params SUBJECT/ENV flame.npz one per subject+environment (13 expressions share it)

Load a single config with:

from datasets import load_dataset
views = load_dataset("mcbuehler/cafca-dataset", "views", streaming=True)
mesh = load_dataset("mcbuehler/cafca-dataset", "scene_mesh", streaming=True)
flame = load_dataset("mcbuehler/cafca-dataset", "flame_params", streaming=True)

Field reference

views (one sample per camera view):

  • rgb.png: RGB color image, 512x512, 8-bit.
  • mask.png: foreground mask, 512x512, 8-bit grayscale (values 0-255).
  • seg.png: semantic segmentation, 512x512, 16-bit grayscale. Region 0 is background; other integer values are semantic regions (facial skin, throat, hair, upper body, eyes, etc.).
  • cam.json: camera parameters, including K, P, world2cam, cam2world, position, orientation, image_size_x/y, focal_length, principal_point_x/y, aspect_ratio, skew, radial_distortion1-3, and tangential_distortion1-2. Right-handed, OpenCV convention (X right, Y down, Z forward).
  • landmark.npz: STAR 2D facial keypoints for this exact view, with bounding_box (1,5) and face_landmark_2d (1,68,3), stored as float32. Note: the original per-camera files use inconsistent float32/float64 dtypes, so we standardize to float32 here for a single consistent schema. This is the only field in this repo that isn't a byte-identical copy of the source.
  • env.json: {"environment": "<name>.exr"}, the HDRI environment map used for this scene.

scene_mesh (one sample per scene, shared by all 30 views of that scene):

  • mesh.obj, mesh.mtl, mesh.jpg: the VHAP-fitted textured FLAME mesh for this expression+environment.

flame_params (one sample per subject+environment, shared by all 13 expressions):

  • flame.npz: FLAME 2023 tracked parameters (rotation, translation, neck_pose, jaw_pose, eyes_pose, shape, expr, tex_extra, lights, static_offset, etc.), fitted via VHAP. Most fields have a leading dimension of 13 (one per expression); a few (shape, tex_extra, lights, static_offset) are shared across all expressions in that subject+environment.

Not included in this repo (present in the original zip):

  • segmentation_rgb: a colorized visualization of segmentation, redundant with it and not used by our own data-loading notebook.
  • flame_2023_ENV/eval_100/image_grid/*.jpg: multi-camera QA preview grids from the fitting pipeline.
  • flame_2023_ENV/*.log: internal fitting logs.

Joining across configs

The three configs are not joined by a uniform prefix rule:

  • scene_mesh key is a true string prefix of the matching views keys. The views key SUBJECT/EXPR_ENV/CAM starts with the scene_mesh key SUBJECT/EXPR_ENV.
  • flame_params key is not a prefix. Derive it from the environment component only: ENV = EXPR_ENV.split("_")[1], then flame_key = f"{SUBJECT}/{ENV}". This tier is small relative to the images, so load it fully into memory and look up by key rather than trying to stream-join two tar iterators:
    flame_by_key = {row["__key__"]: row["flame.npz"] for row in load_dataset(
        "mcbuehler/cafca-dataset", "flame_params", split="train")}
    
    for row in load_dataset("mcbuehler/cafca-dataset", "views", split="train", streaming=True):
        subject, expr_env, cam = row["__key__"].split("/")
        env = expr_env.split("_")[1]
        flame = flame_by_key[f"{subject}/{env}"]
    

Grouping views into scenes or subjects

Within the views config, samples are written in sorted key order (subject, then expr_env, then camera), so consecutive samples belonging to the same scene or subject are contiguous. This lets you group 30 views into one multiview scene, or all views of one subject, at load time with itertools.groupby, with no index needed:

import itertools
from datasets import load_dataset

ds = load_dataset("mcbuehler/cafca-dataset", "views", split="train", streaming=True)

def scene_key(row):
    subject, expr_env, cam = row["__key__"].split("/")
    return f"{subject}/{expr_env}"

for key, group in itertools.groupby(ds, key=scene_key):
    scene_views = list(group)  # all 30 camera views for this scene

Caveat, read this before adding shuffling or multi-worker loading. The grouping above only holds for single-process, sequential, no-shuffle reads. itertools.groupby requires contiguous keys; shards are drained in order so groups stay contiguous, but shuffling, a multi-worker DataLoader, or WebDataset-style shard resampling will interleave samples and make groupby silently produce fragmented, incorrect groups. If you need multiview batches under shuffling, group first, then shuffle at the group level.

Reproducing this conversion (or extending it to more subjects)

scripts/convert_to_webdataset.py and scripts/verify_shards.py in this repo are the exact scripts used to build the shards above, from the raw zips at https://dataset.ait.ethz.ch/downloads/cafca_v2/. They work on any unzipped Cafca chunk, whether single-subject, sample, or a full 100-subject chunk, without modification, since they search recursively for SUBJECT/EXPR_ENV and SUBJECT/flame_2023_ENV directories rather than assuming a fixed folder depth.

pip install webdataset huggingface_hub datasets numpy Pillow trimesh

# Download and unzip a chunk, e.g.:
curl -C - -o chunk.zip https://dataset.ait.ethz.ch/downloads/cafca_v2/00000-00099.zip
unzip chunk.zip -d chunk_00000-00099

python scripts/convert_to_webdataset.py \
    --input-dir chunk_00000-00099 \
    --output-dir shards_00000-00099 \
    --shard-size-mb 500

python scripts/verify_shards.py shards_00000-00099

verify_shards.py decodes samples through both the plain webdataset library and HF datasets, checks the FLAME-params join, the scene-mesh prefix relationship, and the itertools.groupby scene/subject assembly described above. These are the same checks this repo's own shards were validated against before upload.

Citation

@incollection{buehler2024cafca,
  title={Cafca: High-quality Novel View Synthesis of Expressive Faces from Casual Few-shot Captures},
  author={Marcel C. Buehler and Gengyan Li and Erroll Wood and Leonhard Helminger and Xu Chen and Tanmay Shah and Daoye Wang and Stephan Garbin and Sergio Orts-Escolano and Otmar Hilliges and Dmitry Lagun and J\'er\'emy Riviere and Paulo Gotardo and Thabo Beeler and Abhimitra Meka and Kripasindhu Sarkar},
  year={2024},
  booktitle={ACM SIGGRAPH Asia 2024 Conference Paper},
  doi={10.1145/3680528.3687580},
  url={https://doi.org/10.1145/3680528}
}

License

CC BY-NC-SA 4.0, same as the original dataset. See the original project page for full terms.

Downloads last month
33