File size: 773 Bytes
ff0c419
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations

import argparse
from pathlib import Path

from src.ai_image_detector.inference import load_trained_model, predict_image_bytes


def main() -> None:
    parser = argparse.ArgumentParser(description="Predict whether an image is AI-generated.")
    parser.add_argument("image", type=Path, help="Path to the image file")
    args = parser.parse_args()

    if not args.image.exists():
        raise FileNotFoundError(f"Image not found: {args.image}")

    model = load_trained_model()
    result = predict_image_bytes(model, args.image.read_bytes())

    print(f"Prediction: {result.label}")
    print(f"Confidence: {result.confidence:.2%}")
    print(f"AI probability: {result.ai_probability:.2%}")


if __name__ == "__main__":
    main()