CoolFace
Apppublic

moonsunkey/siamese-api

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
App README

๐Ÿ‘ฅ Siamese Network Face Similarity API

A REST API for detecting face similarity and duplicates using a Siamese Neural Network with ResNet18 backbone.

๐Ÿš€ API Endpoints

POST /predict

Compare two face images and get similarity score.

Parameters:

  • โ€”image1: First face image file (JPEG, PNG)
  • โ€”image2: Second face image file (JPEG, PNG)

Response:

json
{
  "similarity_score": 0.95,
  "is_duplicate": true,
  "threshold_used": 0.9,
  "confidence": "high"
}

Confidence levels:

  • โ€”high: similarity > 0.95
  • โ€”medium: similarity > 0.8
  • โ€”low: similarity โ‰ค 0.8

GET /health

Check if the API is running and model is loaded.

Response:

json
{
  "status": "healthy",
  "model": "loaded",
  "device": "cpu"
}

GET /

Get API information and available endpoints.


๐Ÿ“– Usage Examples

Python

python
import requests

url = "https://moonsunkey-siamese-api.hf.space/predict"

files = {
    'image1': open('person1.jpg', 'rb'),
    'image2': open('person2.jpg', 'rb')
}

response = requests.post(url, files=files)
result = response.json()

print(f"Similarity: {result['similarity_score']}")
print(f"Is Duplicate: {result['is_duplicate']}")

cURL

bash
curl -X POST "https://moonsunkey-siamese-api.hf.space/predict" \
  -F "image1=@face1.jpg" \
  -F "image2=@face2.jpg"

JavaScript/Fetch

javascript
const formData = new FormData();
formData.append('image1', file1);
formData.append('image2', file2);

fetch('https://moonsunkey-siamese-api.hf.space/predict', {
  method: 'POST',
  body: formData
})
.then(res => res.json())
.then(data => console.log(data));

๐ŸŽฏ Use Cases

  • โ€”Duplicate Account Detection: Prevent users from creating multiple accounts with the same face
  • โ€”Face Verification: Verify if two images contain the same person
  • โ€”Identity Matching: Match faces across different images
  • โ€”Security Systems: Enhance authentication systems

โš™๏ธ Model Details

  • โ€”Architecture: Siamese Network with ResNet18 backbone
  • โ€”Input Size: 224x224 RGB images
  • โ€”Output: Similarity score (0.0 to 1.0)
  • โ€”Duplicate Threshold: 0.9 (configurable)

๐Ÿ”’ Privacy & Security

  • โ€”Images are processed in real-time and not stored
  • โ€”All processing happens on Hugging Face infrastructure
  • โ€”No data is logged or saved

๐Ÿ“ License

MIT License


๐Ÿค Support

For issues or questions, please open an issue on the repository.