Skip to content

simet.scripts.cifake

simet.scripts.cifake

Utility to download the CIFAKE dataset via KaggleHub.

This module provides a single function, download_cifake_dataset, and a minimal CLI interface:

python cifake.py <path_to_download>
Notes
  • Requires kagglehub and valid Kaggle credentials/config for the environment.
  • Network I/O and disk writes occur; ensure enough free space.

download_cifake_dataset

download_cifake_dataset(path)

Download the CIFAKE dataset to the given directory.

Uses KaggleHub to fetch "birdy654/cifake-real-and-ai-generated-synthetic-images" and stores it under path. Creates the directory if it does not exist.

Parameters:

Name Type Description Default
path Path

Destination directory for the dataset.

required

Returns:

Name Type Description
Path Path

The directory where the dataset was downloaded.

Raises:

Type Description
RuntimeError

If the download fails or credentials are missing.

OSError

For filesystem errors (e.g., permissions, disk full).

Example

download_cifake_dataset(Path("./data/cifake")) # doctest: +SKIP PosixPath('data/cifake')

Source code in simet/scripts/cifake.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
def download_cifake_dataset(path: Path) -> Path:
    """Download the CIFAKE dataset to the given directory.

    Uses KaggleHub to fetch
    `"birdy654/cifake-real-and-ai-generated-synthetic-images"` and stores it
    under `path`. Creates the directory if it does not exist.

    Args:
        path: Destination directory for the dataset.

    Returns:
        Path: The directory where the dataset was downloaded.

    Raises:
        RuntimeError: If the download fails or credentials are missing.
        OSError: For filesystem errors (e.g., permissions, disk full).

    Example:
        >>> download_cifake_dataset(Path("./data/cifake"))  # doctest: +SKIP
        PosixPath('data/cifake')
    """
    path.mkdir(parents=True, exist_ok=True)
    try:
        dataset_download(
            "birdy654/cifake-real-and-ai-generated-synthetic-images",
            path=str(path),
        )
    except Exception as e:  # make failures explicit to callers
        raise RuntimeError(f"Failed to download CIFAKE to {path}: {e}") from e
    return path