Views
No views yet

Human-vs-NonHuman-Detection is an image classification vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for a single-label classification task. It is designed to classify images as either human or non-human using the SiglipForImageClassification architecture.
1Classification Report:
2 precision recall f1-score support
3
4 Human 𖨆 0.9939 0.9735 0.9836 6646
5 Non Human メ 0.9807 0.9956 0.9881 8989
6
7 accuracy 0.9862 15635
8 macro avg 0.9873 0.9845 0.9858 15635
9weighted avg 0.9863 0.9862 0.9862 15635
!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor
3from transformers import SiglipForImageClassification
4from transformers.image_utils import load_image
5from PIL import Image
6import torch
7
8# Load model and processor
9model_name = "prithivMLmods/Human-vs-NonHuman-Detection"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def human_detection(image):
14 """Predicts whether the image contains a human or non-human entity."""
15 image = Image.fromarray(image).convert("RGB")
16 inputs = processor(images=image, return_tensors="pt")
17
18 with torch.no_grad():
19 outputs = model(**inputs)
20 logits = outputs.logits
21 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
23 labels = {
24 "0": "Human 𖨆",
25 "1": "Non Human メ"
26 }
27 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
28
29 return predictions
30
31# Create Gradio interface
32iface = gr.Interface(
33 fn=human_detection,
34 inputs=gr.Image(type="numpy"),
35 outputs=gr.Label(label="Prediction Scores"),
36 title="Human vs Non-Human Detection",
37 description="Upload an image to classify whether it contains a human or non-human entity."
38)
39
40# Launch the app
41if __name__ == "__main__":
42 iface.launch()