Skip to main content

VLM Fraud Detection

A Python library to detect fraud on PNG document images using Google Vertex AI and a few-shot selection pipeline for legitimate examples.

Overview

This package is designed to support research-grade image fraud detection with GCP authentication. It includes:

  • multimodal fraud detection for PNG document images
  • a few-shot selection pipeline for legitimate non-fraud examples
  • a diversity-based selection strategy using image embeddings
  • support for Google Cloud Project authentication via environment variables

Package Usage

Install dependencies:

pip install -r requirements.txt

Configure your environment:

cp .env.example .env

Edit .env with your Google Cloud settings:

PROJECT_ID=your-gcp-project-id
LOCATION=us-central1
MODEL_NAME=gemini-2.5-pro
TEMPERATURE=0.2
MAX_OUTPUT_TOKENS=1024

Example usage:

from vlm_fraud_detection import FraudDetector, FewShotSelector

selector = FewShotSelector()
nonfraud_dataset = [
    "dataset/findit2/val/X00016469619.png",
    "dataset/findit2/val/X00016469620.png",
    # ...
]
selected_examples = selector.select_diverse_examples(nonfraud_dataset, k=10)

detector = FraudDetector()
result = detector.detect_image(
    image_path="dataset/findit2/test/X00016469619.png",
    fewshot_example_paths=selected_examples,
)
print(result)

CLI Usage

Run the package from the command line:

python main.py --image path/to/document.png --dataset-dir path/to/nonfraud-dataset --fewshot-count 10

Or as a module:

python -m vlm_fraud_detection --image path/to/document.png --dataset-dir path/to/nonfraud-dataset

Few-shot Selection

The few-shot pipeline selects representative legitimate examples using these steps:

  1. compute fixed-size embeddings for each PNG image
  2. measure Euclidean distances between embeddings
  3. choose a set of examples that are far apart in embedding space

This helps the model see a broader range of normal documents and improves non-fraud calibration.

Project Structure

.
├── pyproject.toml
├── requirements.txt
├── main.py
├── src/
│   └── vlm_fraud_detection/
│       ├── __init__.py
│       ├── config.py
│       ├── detector.py
│       ├── embeddings.py
│       ├── fewshots.py
│       ├── prompts.py
│       └── cli.py
├── .env.example
└── dataset/

Notes

  • This library currently supports PNG images only.
  • The GCP account must be configured with Application Default Credentials or equivalent Vertex AI access.

References

Metadata

Release files for vlm-fraud-detection 0.1.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 vlm-fraud-detection 0.1.0
File Size Uploaded Provenance
vlm_fraud_detection-0.1.0.tar.gz 20.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for vlm-fraud-detection 0.1.0
File Interpreter ABI Platform
vlm_fraud_detection-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.9 kB

Release files / vlm_fraud_detection-0.1.0.tar.gz

Download URL vlm_fraud_detection-0.1.0.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6657f93d8a00499d9f468f697f8e83b3d5cbd43c417dc5b1b8d1a09f4724b279
BLAKE2b-256 checksum
How to use checksums
9ea02718b5efc325f7903a282602730e41e4a592c3325702dc2ad87182856653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Release files / vlm_fraud_detection-0.1.0-py3-none-any.whl

Download URL vlm_fraud_detection-0.1.0-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
556448786793b622ce7f2093dab20c71ebd685148addfed802485efc53b50d3c
BLAKE2b-256 checksum
How to use checksums
49c0eb3a107b538001c19e3d859397ba74044203b7ad1b5d7ebd9214be500fb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.2

Security for vlm-fraud-detection 0.1.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

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