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")

Metadata

Release files for biasid 1.0.0

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.0
File Size Uploaded Provenance Actions
biasid-1.0.0.tar.gz 11.7 kB Without provenance Details for biasid-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 26.6 kB

Release files / biasid-1.0.0.tar.gz

Download URL biasid-1.0.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
dfbb3c7174ba3551e415157bcff03474a4e2e00677d23b2c61a728d0970c4dc4
BLAKE2b-256 checksum
How to use checksums
e6c6802a8de325383793fc67c89a779fa56ce176c6f70afffdc6cbc4284f4b7a
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.0-py3-none-any.whl

Download URL biasid-1.0.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9896ddc334b6d5737b46b636a38b4a2c4cd12ffc2ca061c3ceac31a116dea6fc
BLAKE2b-256 checksum
How to use checksums
6c49658ddc0e7b1abe7b1d828b4dd4c5f6b02f6743d3796f123b8db4c7903bc9
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.0

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.0 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