Sperm Agglutinine Presence Detector

Model Description

This model detects the presence of agglutinine in human sperm microscopic images using a ResNet50 architecture.

Architecture: ResNet50 with custom classifier head
Task: Binary Image Classification
Classes: Negative, Positive
Input: Single frame, 800x600 RGB
Framework: PyTorch

Intended Use

This model is designed for detecting agglutinine presence in human sperm microscopic images. It's intended for research and diagnostic support in reproductive medicine.

Model Details

  • Input Format: Single RGB image from microscopic video
  • Preprocessing:
    • Resize to 800x600
    • ImageNet normalization
  • Output: Binary classification (Negative/Positive)

Architecture Details

  • Backbone: ResNet50 (pretrained on ImageNet)
  • Classifier Head:
    • Dropout(0.5)
    • Linear(2048 โ†’ 512)
    • ReLU
    • Dropout(0.3)
    • Linear(512 โ†’ 2)

Usage

import torch
import torch.nn as nn
from torchvision import models, transforms
from PIL import Image
import numpy as np

# Define model architecture
model = models.resnet50(pretrained=False)
num_ftrs = model.fc.in_features
model.fc = nn.Sequential(
    nn.Dropout(0.5),
    nn.Linear(num_ftrs, 512),
    nn.ReLU(),
    nn.Dropout(0.3),
    nn.Linear(512, 2)
)

# Load weights
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
checkpoint = torch.load('agglutinine_presence.pth', map_location=device)
model.load_state_dict(checkpoint['model_state_dict'] if 'model_state_dict' in checkpoint else checkpoint)
model.to(device)
model.eval()

# Define preprocessing
transform = transforms.Compose([
    transforms.Resize((600, 800)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

# Load and preprocess image
image = Image.open("path/to/image.jpg").convert('RGB')
image_tensor = transform(image).unsqueeze(0).to(device)

# Inference
with torch.no_grad():
    outputs = model(image_tensor)
    probabilities = torch.softmax(outputs, dim=1)
    predicted_class = torch.argmax(probabilities, dim=1).item()
    confidence = probabilities[0][predicted_class].item()

class_names = ["Negative", "Positive"]
print(f"Prediction: {class_names[predicted_class]}")
print(f"Confidence: {confidence:.4f}")
print(f"Positive probability: {probabilities[0][1].item():.4f}")

Limitations

  • Trained on specific microscopy equipment and protocols
  • Performance may vary with different imaging conditions
  • Should be used as diagnostic support, not sole decision-making tool
  • Single-frame analysis may not capture temporal dynamics

Citation

If you use this model, please cite:

@misc{sperm-agglutinine-detector,
  author = {Raid Athmane Benlala},
  title = {Sperm Agglutinine Presence Detector},
  year = {2025},
  publisher = {Hugging Face},
  howpublished = {\url{https://huggingface.co/raidAthmaneBenlala/agglutinine-detector}}
}
Downloads last month
2
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support