Image Classification
Transformers
ONNX
Safetensors
Transformers.js
dinov2
ai-image-detection
deepfake-detection
image-forensics
agent-forensics
Run this model with HF Jobs
Run Tamarillo/ai-image-forensics-guard-tiny on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/Tamarillo/ai-image-forensics-guard-tiny. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/Tamarillo/ai-image-forensics-guard-tiny on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use Tamarillo/ai-image-forensics-guard-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Tamarillo/ai-image-forensics-guard-tiny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="Tamarillo/ai-image-forensics-guard-tiny") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# pip install -U transformers accelerate # Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("Tamarillo/ai-image-forensics-guard-tiny") model = AutoModelForImageClassification.from_pretrained("Tamarillo/ai-image-forensics-guard-tiny", device_map="auto") - Transformers.js
How to use Tamarillo/ai-image-forensics-guard-tiny with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-classification', 'Tamarillo/ai-image-forensics-guard-tiny'); - Notebooks
- Google Colab
- Kaggle
Release Tamarillo/ai-image-forensics-guard-tiny v2 (Apache-2.0, Stage-2 PASS, FLUX.1+DiT full-diffusion & FP16 ONNX)
656e994 verified Download scripts/prepare_v2_manifests.py from Tamarillo/ai-image-forensics-guard-tiny: direct link, hf CLI and curl.
- Browser
- Download file 7.2 kB
-
https://huggingface.co/Tamarillo/ai-image-forensics-guard-tiny/resolve/main/scripts/prepare_v2_manifests.py
- Command line
-
hf download hf://Tamarillo/ai-image-forensics-guard-tiny/scripts/prepare_v2_manifests.py
-
curl -L -o prepare_v2_manifests.py https://huggingface.co/Tamarillo/ai-image-forensics-guard-tiny/resolve/main/scripts/prepare_v2_manifests.py
7.2 kB
| """Merge cached v2 image archives on GPU VM local SSD (/tmp/img_v2_work) in ~15 seconds: | |
| 1. img_base_cache_v2.tar (12,000 openimages + 12,000 CommunityForensics + 5 frozen Public OOD suites) | |
| 2. matched_2026_pairs.tar (8,000 v1 1:1 COCO + SANA-Sprint/SANA-1.5/Lumina-2.0/SSD-1B pairs) | |
| 3. bfree_flux_v2.tar (6,000 B-Free Multi-VAE pairs + 1,800 FLUX.1-schnell pairs + 600 Shuttle-3 OOD pairs) | |
| Strictly keeps `ood_shuttle3_test` (Shuttle-3) OUT of train/val and writes it as a 6th OOD eval suite! | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import random | |
| import tarfile | |
| import time | |
| from collections import Counter | |
| from pathlib import Path | |
| from typing import Any | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--base-cache-tar", type=str, required=True) | |
| ap.add_argument("--extra-cache-tar", type=str, default="") | |
| ap.add_argument("--v1-pairs-tar", type=str, required=True) | |
| ap.add_argument("--v2-bfree-tar", type=str, required=True) | |
| ap.add_argument("--bfree-max-per-vae", type=int, default=0, help="0 = exclude B-Free VAE-only reconstructions (full-diffusion only!)") | |
| ap.add_argument("--out-dir", type=str, default="/tmp/img_v2_work") | |
| args = ap.parse_args() | |
| t0 = time.time() | |
| root = Path(args.out_dir) | |
| root.mkdir(parents=True, exist_ok=True) | |
| # 1. Extract base cache (openimages + commfor + 5 frozen OOD suites) | |
| base_dir = root / "base_cache" | |
| base_dir.mkdir(parents=True, exist_ok=True) | |
| print(f"[merge 1/3] Extracting {args.base_cache_tar}...", flush=True) | |
| with tarfile.open(args.base_cache_tar, "r") as tf: | |
| tf.extractall(base_dir) | |
| train_rows: list[dict[str, Any]] = [] | |
| val_rows: list[dict[str, Any]] = [] | |
| for r in (json.loads(l) for l in (base_dir / "base_train.jsonl").read_text(encoding="utf-8").splitlines() if l.strip()): | |
| train_rows.append({**r, "path": str(base_dir / r["rel"])}) | |
| for r in (json.loads(l) for l in (base_dir / "base_val.jsonl").read_text(encoding="utf-8").splitlines() if l.strip()): | |
| val_rows.append({**r, "path": str(base_dir / r["rel"])}) | |
| # Rewrite OOD manifests with absolute paths | |
| ood_out = root / "ood" | |
| ood_out.mkdir(parents=True, exist_ok=True) | |
| for jp in sorted((base_dir / "ood").glob("*.jsonl")): | |
| fixed = [] | |
| for r in (json.loads(l) for l in jp.read_text(encoding="utf-8").splitlines() if l.strip()): | |
| fixed.append({**r, "path": str(base_dir / r["rel"])}) | |
| (ood_out / jp.name).write_text("\n".join(json.dumps(x) for x in fixed) + "\n", encoding="utf-8") | |
| # Optional 1B: Extract extra full-diffusion cache (+24K openimages + 24K CommunityForensics across 100+ shards!) | |
| if args.extra_cache_tar and Path(args.extra_cache_tar).exists(): | |
| ex_dir = root / "extra_cache" | |
| ex_dir.mkdir(parents=True, exist_ok=True) | |
| print(f"[merge 1B] Extracting {args.extra_cache_tar}...", flush=True) | |
| with tarfile.open(args.extra_cache_tar, "r") as tf: | |
| tf.extractall(ex_dir) | |
| for r in (json.loads(l) for l in (ex_dir / "extra_train.jsonl").read_text(encoding="utf-8").splitlines() if l.strip()): | |
| train_rows.append({**r, "path": str(ex_dir / r["rel"])}) | |
| for r in (json.loads(l) for l in (ex_dir / "extra_val.jsonl").read_text(encoding="utf-8").splitlines() if l.strip()): | |
| val_rows.append({**r, "path": str(ex_dir / r["rel"])}) | |
| # 2. Extract v1 matched_2026_pairs.tar (SANA-Sprint, SANA-1.5, Lumina-2.0, SSD-1B) | |
| v1_dir = root / "matched_v1" | |
| v1_dir.mkdir(parents=True, exist_ok=True) | |
| print(f"[merge 2/3] Extracting {args.v1_pairs_tar}...", flush=True) | |
| with tarfile.open(args.v1_pairs_tar, "r") as tf: | |
| tf.extractall(v1_dir) | |
| v1_man = [json.loads(l) for l in (v1_dir / "manifest.jsonl").read_text(encoding="utf-8").splitlines() if l.strip()] | |
| random.Random(42).shuffle(v1_man) | |
| by_g1: dict[str, list[dict[str, Any]]] = {} | |
| for r in v1_man: | |
| by_g1.setdefault(r["generator"], []).append(r) | |
| for gname, grows in sorted(by_g1.items()): | |
| n_val = min(120, len(grows) // 8) | |
| for idx, r in enumerate(grows): | |
| tgt = val_rows if idx < n_val else train_rows | |
| tgt.append({"path": str(v1_dir / r["real_rel"]), "label": 1, "source": f"coco_v1_{gname}", "weight": 2.0}) | |
| tgt.append({"path": str(v1_dir / r["fake_rel"]), "label": 0, "source": f"gen_v1_{gname}", "weight": 2.0}) | |
| # 3. Extract v2 bfree_flux_v2.tar (6,000 B-Free Multi-VAE + 1,800 FLUX.1-schnell + 600 Shuttle-3 OOD) | |
| v2_dir = root / "bfree_v2" | |
| v2_dir.mkdir(parents=True, exist_ok=True) | |
| print(f"[merge 3/3] Extracting {args.v2_bfree_tar}...", flush=True) | |
| with tarfile.open(args.v2_bfree_tar, "r") as tf: | |
| tf.extractall(v2_dir) | |
| v2_man = [json.loads(l) for l in (v2_dir / "manifest.jsonl").read_text(encoding="utf-8").splitlines() if l.strip()] | |
| random.Random(2026).shuffle(v2_man) | |
| shuttle_ood: list[dict[str, Any]] = [] | |
| by_g2: dict[str, list[dict[str, Any]]] = {} | |
| for r in v2_man: | |
| if r.get("split") == "ood_shuttle3_test": | |
| shuttle_ood.append({"path": str(v2_dir / r["real_rel"]), "label": 1, "model": "coco_real"}) | |
| shuttle_ood.append({"path": str(v2_dir / r["fake_rel"]), "label": 0, "model": "shuttle-3-diffusion"}) | |
| else: | |
| by_g2.setdefault(r["generator"], []).append(r) | |
| for gname, grows in sorted(by_g2.items()): | |
| is_bfree = gname.startswith("bfree_") | |
| if is_bfree: | |
| if args.bfree_max_per_vae <= 0: | |
| continue | |
| grows = grows[: args.bfree_max_per_vae] | |
| n_val = min(150, len(grows) // 8) | |
| w = 2.5 if gname == "flux1_schnell" else 1.0 | |
| for idx, r in enumerate(grows): | |
| tgt = val_rows if idx < n_val else train_rows | |
| tgt.append({"path": str(v2_dir / r["real_rel"]), "label": 1, "source": f"coco_v2_{gname}", "weight": w}) | |
| tgt.append({"path": str(v2_dir / r["fake_rel"]), "label": 0, "source": f"v2_{gname}", "weight": w}) | |
| random.Random(2026).shuffle(shuttle_ood) | |
| (ood_out / "ood_shuttle3_2026.jsonl").write_text("\n".join(json.dumps(x) for x in shuttle_ood) + "\n", encoding="utf-8") | |
| random.Random(2026).shuffle(train_rows) | |
| random.Random(2027).shuffle(val_rows) | |
| (root / "train.jsonl").write_text("\n".join(json.dumps(x) for x in train_rows) + "\n", encoding="utf-8") | |
| (root / "val.jsonl").write_text("\n".join(json.dumps(x) for x in val_rows) + "\n", encoding="utf-8") | |
| summary = { | |
| "train_n": len(train_rows), | |
| "train_by_label": dict(Counter(r["label"] for r in train_rows)), | |
| "train_by_source": dict(Counter(r["source"] for r in train_rows)), | |
| "val_n": len(val_rows), | |
| "val_by_label": dict(Counter(r["label"] for r in val_rows)), | |
| "shuttle3_ood_n": len(shuttle_ood), | |
| "elapsed_s": round(time.time() - t0, 1), | |
| } | |
| (root / "v2_merge_summary.json").write_text(json.dumps(summary, indent=2), encoding="utf-8") | |
| print(f"[DONE] Merged v2 manifests in {summary['elapsed_s']}s: {json.dumps(summary, indent=2)}", flush=True) | |
| if __name__ == "__main__": | |
| main() | |