Views
No views yet

OpenSDI-Flux.1-SigLIP2 is a vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for binary image classification. It is trained to detect whether an image is a real photograph or generated using the Flux.1 generative model, based on the SiglipForImageClassification architecture.
[!note] SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features https://arxiv.org/pdf/2502.14786
[!note] OpenSDI: Spotting Diffusion-Generated Images in the Open World https://arxiv.org/pdf/2503.19653, OpenSDI Flux.1 SigLIP2 works best with crisp and high-quality images. Noisy images are not recommended for validation.
[!warning] If the task is based on image content moderation or AI-generated image vs. real image classification, it is recommended to use this model.
1Classification Report:
2 precision recall f1-score support
3
4 Real_Image 0.9108 0.9238 0.9172 10000
5Flux.1_Generated 0.9227 0.9095 0.9160 10000
6
7 accuracy 0.9166 20000
8 macro avg 0.9167 0.9166 0.9166 20000
9 weighted avg 0.9167 0.9166 0.9166 20000
Class 0: Real_Image
Class 1: Flux.1_Generatedpip install -q transformers torch pillow gradio hf_xet1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from PIL import Image
4import torch
5
6# Load model and processor
7model_name = "prithivMLmods/OpenSDI-Flux.1-SigLIP2" # Update if needed
8model = SiglipForImageClassification.from_pretrained(model_name)
9processor = AutoImageProcessor.from_pretrained(model_name)
10
11# Label mapping
12id2label = {
13 "0": "Real_Image",
14 "1": "Flux.1_Generated"
15}
16
17def classify_image(image):
18 image = Image.fromarray(image).convert("RGB")
19 inputs = processor(images=image, return_tensors="pt")
20
21 with torch.no_grad():
22 outputs = model(**inputs)
23 logits = outputs.logits
24 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
25
26 prediction = {
27 id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
28 }
29
30 return prediction
31
32# Gradio Interface
33iface = gr.Interface(
34 fn=classify_image,
35 inputs=gr.Image(type="numpy"),
36 outputs=gr.Label(num_top_classes=2, label="Flux.1 Image Detection"),
37 title="OpenSDI-Flux.1-SigLIP2",
38 description="Upload an image to determine whether it is a real photograph or generated by Flux.1."
39)
40
41if __name__ == "__main__":
42 iface.launch()[!warning] Flux.1 Generated
| Image 1 | Image 2 |
|---|---|
![]() | ![]() |
[!warning] Real Image
| Image 1 | Image 2 |
|---|---|
![]() | ![]() |