Skip to main content

biasid - A Tool for Analyzing Transformation Bias and Robustness of AI-Generated Image Detectors

Installation

pip install biasid

Usage

import matplotlib.pyplot as plt
import torch
from torch import nn
from torchvision.transforms import v2

from biasid import DetectorWrapper, compute_metrics, create_bias_plot, get_score_df
from biasid.datasets import FolderDataset
from biasid.transforms import JPEG


# toy detector, use your own instead
class MyDetector(nn.Module):
    def __init__(self):
        super().__init__()
        self.layer = nn.Linear(3 * 32 * 32, 1)

    def forward(self, images):
        return self.layer(images.flatten(start_dim=1))


if __name__ == "__main__":
    my_detector = MyDetector()

    # wrap your model into DetectorWrapper
    detector = DetectorWrapper(
        model=my_detector,
        preprocessing=v2.CenterCrop(32),
        postprocessing=torch.sigmoid,
    )

    # define datasets
    real = FolderDataset(root="real")
    fake = FolderDataset(root="fake")

    # define a transformation
    jpeg = JPEG()

    # compute scores
    score_df = get_score_df(
        detector=detector,
        real_dataset=real,
        fake_dataset=fake,
        output_dir="output/scores",
        transform=jpeg,
        batch_size=8,
        num_workers=4,
    )

    # compute metrics (with bootstrapping)
    metrics = compute_metrics(score_df)
    metrics.save("output/metrics")

    # visualize results
    create_bias_plot(result=metrics, real_subset="real", fake_subset="fake")
    plt.savefig("output/plots/jpeg.png")

Notes

  • It is expected that the real and fake dataset contain the same number of images. If they are semantically aligned, they should have the same order s.t. during bootstrapping the matching is preserved.

Metadata

Release files for biasid 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for biasid 1.0.1
File Size Uploaded Provenance Actions
biasid-1.0.1.tar.gz 11.9 kB Without provenance Details for biasid-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for biasid 1.0.1
File Interpreter ABI Platform Actions
biasid-1.0.1-py3-none-any.whl Python 3 none any Details for biasid-1.0.1-py3-none-any.whl

Total release size: 27.1 kB

Release files / biasid-1.0.1.tar.gz

Download URL biasid-1.0.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
01a556c0f5d79e19775549f0280968c3208c8fe29753bee6d244d4cb0b6aca84
BLAKE2b-256 checksum
How to use checksums
a4d18dd17907251f37401ea5bddda6ba0dd774ba8ae532427f861510e1e0e6b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.04","id":"plucky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / biasid-1.0.1-py3-none-any.whl

Download URL biasid-1.0.1-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c273c57d0254570124ba30c72e1c71704b440cbfe01fd2033bb9282ef31aee9a
BLAKE2b-256 checksum
How to use checksums
da3d3c3c61c7d6d32f5cd3d6642c48a458334932e978eb0e33efc026ee948253
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.04","id":"plucky","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for biasid 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page