Spaces:
Running

facecheck / index.html
bozz723's picture
Add 2 files
e1f2e52 verified
Raw History Blame Contribute Delete
40.7 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FaceMatch - AI Facial Recognition Search</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/face-api.js@0.22.2/dist/face-api.min.js"></script>
<style>
.dropzone {
border: 2px dashed #3b82f6;
border-radius: 0.5rem;
transition: all 0.3s ease;
}
.dropzone.active {
border-color: #10b981;
background-color: rgba(16, 185, 129, 0.05);
}
.result-card {
transition: all 0.3s ease;
}
.result-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.loading-spinner {
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.face-box {
position: absolute;
border: 2px solid #3b82f6;
background-color: rgba(59, 130, 246, 0.2);
}
.similarity-meter {
height: 6px;
background: linear-gradient(90deg, #ef4444, #f59e0b, #10b981);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- Header remains the same -->
<header class="bg-white shadow-sm">
<div class="container mx-auto px-4 py-4 flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-user-circle text-blue-500 text-3xl"></i>
<h1 class="text-2xl font-bold text-gray-800">FaceMatch</h1>
</div>
<nav class="hidden md:flex space-x-6">
<a href="#" class="text-gray-600 hover:text-blue-500">Home</a>
<a href="#" class="text-gray-600 hover:text-blue-500">How it works</a>
<a href="#" class="text-gray-600 hover:text-blue-500">API</a>
<a href="#" class="text-gray-600 hover:text-blue-500">Pricing</a>
<a href="#" class="text-gray-600 hover:text-blue-500">Blog</a>
</nav>
<div class="flex items-center space-x-4">
<button class="px-4 py-2 text-gray-600 hover:text-blue-500">
<i class="fas fa-user"></i>
</button>
<button class="md:hidden text-gray-600">
<i class="fas fa-bars"></i>
</button>
</div>
</div>
</header>
<main class="container mx-auto px-4 py-8">
<section class="text-center mb-12">
<h2 class="text-4xl font-bold text-gray-800 mb-4">AI Facial Recognition Search</h2>
<p class="text-xl text-gray-600 max-w-3xl mx-auto">
Upload a photo to find similar faces across the internet. Our powerful AI scans millions of images to find matches.
</p>
</section>
<section class="max-w-4xl mx-auto mb-12">
<div class="bg-white rounded-xl shadow-md p-6">
<div class="flex flex-col md:flex-row gap-6">
<div class="flex-1">
<div id="dropzone" class="dropzone p-8 text-center cursor-pointer">
<div class="flex flex-col items-center justify-center h-full">
<i class="fas fa-cloud-upload-alt text-blue-500 text-5xl mb-4"></i>
<h3 class="text-xl font-semibold text-gray-700 mb-2">Drag & Drop your photo here</h3>
<p class="text-gray-500 mb-4">or click to browse files</p>
<input type="file" id="fileInput" class="hidden" accept="image/*">
<button id="uploadBtn" class="bg-blue-500 hover:bg-blue-600 text-white px-6 py-2 rounded-lg transition">
Select Image
</button>
<p class="text-xs text-gray-400 mt-4">Supports JPG, PNG, WEBP (Max 5MB)</p>
</div>
</div>
</div>
<div class="flex-1">
<div class="border border-gray-200 rounded-lg p-4 h-full">
<h3 class="text-lg font-semibold text-gray-700 mb-4">Search Options</h3>
<div class="space-y-4">
<div>
<label class="block text-gray-600 mb-2">Search Scope</label>
<select id="searchScope" class="w-full p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
<option value="web">Entire Internet</option>
<option value="social">Social Media Only</option>
<option value="news">News Websites</option>
<option value="public">Public Figures</option>
</select>
</div>
<div>
<label class="block text-gray-600 mb-2">Match Sensitivity</label>
<input id="sensitivity" type="range" min="50" max="100" value="80" class="w-full">
<div class="flex justify-between text-xs text-gray-500">
<span>Loose</span>
<span>Balanced</span>
<span>Strict</span>
</div>
</div>
<div class="flex items-center">
<input type="checkbox" id="nsfwFilter" class="mr-2" checked>
<label for="nsfwFilter" class="text-gray-600">Filter NSFW content</label>
</div>
<button id="searchBtn" class="w-full bg-blue-500 hover:bg-blue-600 text-white py-3 rounded-lg font-medium transition opacity-50 cursor-not-allowed" disabled>
Start Search
</button>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="previewSection" class="hidden max-w-4xl mx-auto mb-12">
<div class="bg-white rounded-xl shadow-md p-6">
<h3 class="text-xl font-semibold text-gray-700 mb-4">Image Preview</h3>
<div class="flex flex-col md:flex-row gap-6">
<div class="flex-1 relative">
<img id="previewImage" src="" alt="Preview" class="w-full rounded-lg">
<div id="faceBoxes"></div>
</div>
<div class="flex-1">
<div class="bg-gray-50 p-4 rounded-lg">
<h4 class="font-medium text-gray-700 mb-2">Detected Faces</h4>
<div id="faceList" class="space-y-3">
<!-- Faces will be added here dynamically -->
</div>
<div class="mt-4">
<button id="analyzeBtn" class="w-full bg-blue-500 hover:bg-blue-600 text-white py-3 rounded-lg font-medium transition">
Analyze Selected Faces
</button>
</div>
</div>
</div>
</div>
</div>
</section>
<section id="loadingSection" class="hidden max-w-4xl mx-auto mb-12 text-center py-12">
<div class="bg-white rounded-xl shadow-md p-8">
<div class="inline-block loading-spinner text-blue-500 text-5xl mb-6">
<i class="fas fa-spinner"></i>
</div>
<h3 class="text-2xl font-semibold text-gray-700 mb-2">Searching the web for matches</h3>
<p class="text-gray-500 mb-6">This may take a few moments...</p>
<div class="w-full bg-gray-200 rounded-full h-2.5">
<div id="progressBar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
</div>
<p id="progressText" class="text-sm text-gray-500 mt-2">Initializing search...</p>
</div>
</section>
<section id="resultsSection" class="hidden max-w-6xl mx-auto mb-12">
<div class="bg-white rounded-xl shadow-md p-6">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-semibold text-gray-700">Search Results</h3>
<div class="flex items-center space-x-2">
<span class="text-gray-500">Sort by:</span>
<select id="sortResults" class="p-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500">
<option value="similarity">Best Match</option>
<option value="date">Most Recent</option>
<option value="source">Source Website</option>
</select>
</div>
</div>
<div id="resultsStats" class="mb-4 text-gray-600">
<!-- Results stats will appear here -->
</div>
<div id="resultsContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Results will be added here dynamically -->
</div>
<div class="mt-8 text-center">
<button id="loadMoreBtn" class="hidden bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded-lg font-medium transition">
Load More Results
</button>
</div>
</div>
</section>
<!-- How it works section remains the same -->
<section class="max-w-4xl mx-auto mb-12 bg-blue-50 rounded-xl p-8">
<h3 class="text-2xl font-semibold text-gray-700 mb-4 text-center">How FaceMatch Works</h3>
<div class="grid md:grid-cols-3 gap-6">
<div class="text-center p-4">
<div class="bg-blue-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-upload text-blue-500 text-2xl"></i>
</div>
<h4 class="font-medium text-gray-700 mb-2">Upload Image</h4>
<p class="text-gray-600">Upload a clear photo containing the face you want to search for.</p>
</div>
<div class="text-center p-4">
<div class="bg-blue-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-brain text-blue-500 text-2xl"></i>
</div>
<h4 class="font-medium text-gray-700 mb-2">AI Analysis</h4>
<p class="text-gray-600">Our AI extracts facial features and creates a unique fingerprint.</p>
</div>
<div class="text-center p-4">
<div class="bg-blue-100 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-search text-blue-500 text-2xl"></i>
</div>
<h4 class="font-medium text-gray-700 mb-2">Get Results</h4>
<p class="text-gray-600">Find matching faces across millions of images from public sources.</p>
</div>
</div>
</section>
</main>
<!-- Footer remains the same -->
<footer class="bg-gray-800 text-white py-12">
<div class="container mx-auto px-4">
<div class="grid grid-cols-1 md:grid-cols-4 gap-8">
<div>
<h4 class="text-xl font-semibold mb-4">FaceMatch</h4>
<p class="text-gray-400">Advanced facial recognition technology to help you find people across the internet.</p>
</div>
<div>
<h4 class="text-lg font-semibold mb-4">Company</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white">About Us</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Careers</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Press</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Contact</a></li>
</ul>
</div>
<div>
<h4 class="text-lg font-semibold mb-4">Legal</h4>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white">Privacy Policy</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Terms of Service</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Data Processing</a></li>
<li><a href="#" class="text-gray-400 hover:text-white">Cookie Policy</a></li>
</ul>
</div>
<div>
<h4 class="text-lg font-semibold mb-4">Connect</h4>
<div class="flex space-x-4">
<a href="#" class="text-gray-400 hover:text-white text-xl"><i class="fab fa-twitter"></i></a>
<a href="#" class="text-gray-400 hover:text-white text-xl"><i class="fab fa-facebook"></i></a>
<a href="#" class="text-gray-400 hover:text-white text-xl"><i class="fab fa-instagram"></i></a>
<a href="#" class="text-gray-400 hover:text-white text-xl"><i class="fab fa-linkedin"></i></a>
</div>
<div class="mt-4">
<p class="text-gray-400">Subscribe to our newsletter</p>
<div class="flex mt-2">
<input type="email" placeholder="Your email" class="px-3 py-2 text-gray-800 rounded-l">
<button class="bg-blue-500 hover:bg-blue-600 px-4 py-2 rounded-r">
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>
</div>
</div>
<div class="border-t border-gray-700 mt-8 pt-8 text-center text-gray-400">
<p>© 2023 FaceMatch. All rights reserved.</p>
</div>
</div>
</footer>
<script>
// Load face-api.js models
async function loadModels() {
try {
await faceapi.nets.tinyFaceDetector.loadFromUri('https://justadudewhohacks.github.io/face-api.js/models');
await faceapi.nets.faceLandmark68Net.loadFromUri('https://justadudewhohacks.github.io/face-api.js/models');
await faceapi.nets.faceRecognitionNet.loadFromUri('https://justadudewhohacks.github.io/face-api.js/models');
await faceapi.nets.ssdMobilenetv1.loadFromUri('https://justadudewhohacks.github.io/face-api.js/models');
console.log('All models loaded successfully');
} catch (error) {
console.error('Error loading models:', error);
alert('Failed to load AI models. Please refresh the page.');
}
}
// Call loadModels when the page loads
document.addEventListener('DOMContentLoaded', loadModels);
// DOM elements
const dropzone = document.getElementById('dropzone');
const fileInput = document.getElementById('fileInput');
const uploadBtn = document.getElementById('uploadBtn');
const searchBtn = document.getElementById('searchBtn');
const previewSection = document.getElementById('previewSection');
const previewImage = document.getElementById('previewImage');
const faceBoxes = document.getElementById('faceBoxes');
const faceList = document.getElementById('faceList');
const analyzeBtn = document.getElementById('analyzeBtn');
const loadingSection = document.getElementById('loadingSection');
const resultsSection = document.getElementById('resultsSection');
const resultsContainer = document.getElementById('resultsContainer');
const progressBar = document.getElementById('progressBar');
const progressText = document.getElementById('progressText');
const searchScope = document.getElementById('searchScope');
const sensitivity = document.getElementById('sensitivity');
const nsfwFilter = document.getElementById('nsfwFilter');
const sortResults = document.getElementById('sortResults');
const loadMoreBtn = document.getElementById('loadMoreBtn');
const resultsStats = document.getElementById('resultsStats');
// Global variables
let selectedFaceIndex = 0;
let detectedFaces = [];
let currentSearchDescriptor = null;
let searchResults = [];
let currentPage = 1;
const resultsPerPage = 6;
// Event listeners
uploadBtn.addEventListener('click', () => fileInput.click());
fileInput.addEventListener('change', handleFileSelect);
dropzone.addEventListener('dragover', (e) => {
e.preventDefault();
dropzone.classList.add('active');
});
dropzone.addEventListener('dragleave', () => {
dropzone.classList.remove('active');
});
dropzone.addEventListener('drop', (e) => {
e.preventDefault();
dropzone.classList.remove('active');
if (e.dataTransfer.files.length) {
fileInput.files = e.dataTransfer.files;
handleFileSelect({ target: fileInput });
}
});
analyzeBtn.addEventListener('click', startSearch);
searchBtn.addEventListener('click', startSearch);
sortResults.addEventListener('change', sortAndDisplayResults);
loadMoreBtn.addEventListener('click', loadMoreResults);
// Handle file selection
async function handleFileSelect(event) {
const file = event.target.files[0];
if (!file) return;
if (!file.type.match('image.*')) {
alert('Please select an image file (JPG, PNG, WEBP)');
return;
}
if (file.size > 5 * 1024 * 1024) {
alert('File size exceeds 5MB limit');
return;
}
// Display preview
const reader = new FileReader();
reader.onload = async (e) => {
previewImage.src = e.target.result;
previewSection.classList.remove('hidden');
// Clear previous results
resultsSection.classList.add('hidden');
searchResults = [];
currentPage = 1;
// Detect faces
await detectFaces(previewImage);
// Enable search button
searchBtn.disabled = false;
searchBtn.classList.remove('opacity-50', 'cursor-not-allowed');
};
reader.readAsDataURL(file);
}
// Detect faces in image
async function detectFaces(image) {
faceBoxes.innerHTML = '';
faceList.innerHTML = '';
detectedFaces = [];
// Wait for image to load
await new Promise((resolve) => {
if (image.complete) {
resolve();
} else {
image.onload = resolve;
}
});
try {
const detections = await faceapi.detectAllFaces(image, new faceapi.SsdMobilenetv1Options())
.withFaceLandmarks()
.withFaceDescriptors();
if (detections.length === 0) {
faceList.innerHTML = '<p class="text-gray-500">No faces detected</p>';
return;
}
// Store detected faces globally
detectedFaces = detections;
// Display face boxes
const displaySize = { width: image.width, height: image.height };
const resizedDetections = faceapi.resizeResults(detections, displaySize);
resizedDetections.forEach((detection, i) => {
const box = detection.detection.box;
const faceBox = document.createElement('div');
faceBox.className = 'face-box';
faceBox.style.left = `${box.x}px`;
faceBox.style.top = `${box.y}px`;
faceBox.style.width = `${box.width}px`;
faceBox.style.height = `${box.height}px`;
faceBox.dataset.index = i;
faceBoxes.appendChild(faceBox);
// Add face to list
const faceItem = document.createElement('div');
faceItem.className = 'flex items-center p-2 bg-white rounded-md cursor-pointer hover:bg-blue-50 border border-transparent';
faceItem.dataset.index = i;
const faceThumb = document.createElement('div');
faceThumb.className = 'relative w-12 h-12 mr-3 overflow-hidden';
const faceImg = document.createElement('img');
faceImg.src = previewImage.src;
faceImg.className = 'w-full h-full object-cover rounded';
faceThumb.appendChild(faceImg);
const faceBoxThumb = document.createElement('div');
faceBoxThumb.className = 'absolute border-2 border-blue-500';
faceBoxThumb.style.left = `${-box.x / (image.naturalWidth / image.width)}px`;
faceBoxThumb.style.top = `${-box.y / (image.naturalHeight / image.height)}px`;
faceBoxThumb.style.width = `${box.width / (image.naturalWidth / image.width)}px`;
faceBoxThumb.style.height = `${box.height / (image.naturalHeight / image.height)}px`;
faceThumb.appendChild(faceBoxThumb);
const faceLabel = document.createElement('div');
faceLabel.innerHTML = `
<span class="block font-medium">Face ${i + 1}</span>
<span class="text-xs text-gray-500">${Math.round(detection.detection.score * 100)}% confidence</span>
`;
faceItem.appendChild(faceThumb);
faceItem.appendChild(faceLabel);
faceList.appendChild(faceItem);
// Highlight face when hovering over list item
faceItem.addEventListener('mouseenter', () => {
faceBox.style.borderColor = '#10b981';
faceBox.style.backgroundColor = 'rgba(16, 185, 129, 0.3)';
});
faceItem.addEventListener('mouseleave', () => {
if (parseInt(faceItem.dataset.index) !== selectedFaceIndex) {
faceBox.style.borderColor = '#3b82f6';
faceBox.style.backgroundColor = 'rgba(59, 130, 246, 0.2)';
}
});
// Select face when clicked
faceItem.addEventListener('click', () => {
selectedFaceIndex = parseInt(faceItem.dataset.index);
document.querySelectorAll('#faceList div').forEach(item => {
item.classList.remove('bg-blue-100', 'border-blue-500');
});
faceItem.classList.add('bg-blue-100', 'border-blue-500');
// Highlight the selected face box
document.querySelectorAll('.face-box').forEach(box => {
box.style.borderColor = '#3b82f6';
box.style.backgroundColor = 'rgba(59, 130, 246, 0.2)';
});
faceBox.style.borderColor = '#10b981';
faceBox.style.backgroundColor = 'rgba(16, 185, 129, 0.3)';
});
});
// Select first face by default
if (faceList.firstChild) {
faceList.firstChild.click();
}
} catch (error) {
console.error('Error detecting faces:', error);
faceList.innerHTML = '<p class="text-red-500">Error detecting faces. Please try another image.</p>';
}
}
// Start search
function startSearch() {
if (detectedFaces.length === 0) {
alert('No faces detected in the image');
return;
}
// Get the selected face descriptor
currentSearchDescriptor = detectedFaces[selectedFaceIndex].descriptor;
previewSection.classList.add('hidden');
loadingSection.classList.remove('hidden');
resultsSection.classList.add('hidden');
// Simulate progress with actual API calls in a real implementation
simulateSearchProgress();
}
// Simulate search progress (replace with actual API calls in production)
function simulateSearchProgress() {
let progress = 0;
const interval = setInterval(() => {
progress += Math.random() * 10;
if (progress > 100) progress = 100;
progressBar.style.width = `${progress}%`;
if (progress < 30) {
progressText.textContent = 'Indexing facial features...';
} else if (progress < 60) {
progressText.textContent = 'Searching public databases...';
} else if (progress < 90) {
progressText.textContent = 'Analyzing potential matches...';
} else {
progressText.textContent = 'Finalizing results...';
}
if (progress === 100) {
clearInterval(interval);
// In a real implementation, you would make API calls here
// For this demo, we'll use mock data after a short delay
setTimeout(() => {
// Generate mock results based on search parameters
generateMockResults().then(() => {
loadingSection.classList.add('hidden');
resultsSection.classList.remove('hidden');
displayResults();
});
}, 500);
}
}, 500);
}
// Generate mock results based on search parameters
async function generateMockResults() {
// Clear previous results
searchResults = [];
currentPage = 1;
// Get search parameters
const scope = searchScope.value;
const minSimilarity = 100 - sensitivity.value; // Convert sensitivity to minimum similarity
// Generate different results based on scope
const baseResults = [];
const resultCount = Math.floor(Math.random() * 50) + 30; // 30-80 results
for (let i = 0; i < resultCount; i++) {
let similarity = Math.floor(Math.random() * (100 - minSimilarity + 1)) + minSimilarity;
similarity = Math.min(100, similarity + 5); // Bias toward higher similarity
let result;
if (scope === 'social') {
result = generateSocialMediaResult(i, similarity);
} else if (scope === 'news') {
result = generateNewsResult(i, similarity);
} else if (scope === 'public') {
result = generatePublicFigureResult(i, similarity);
} else {
// Mixed results for 'web' scope
const types = ['social', 'news', 'public', 'forum', 'blog'];
const type = types[Math.floor(Math.random() * types.length)];
switch (type) {
case 'social':
result = generateSocialMediaResult(i, similarity);
break;
case 'news':
result = generateNewsResult(i, similarity);
break;
case 'public':
result = generatePublicFigureResult(i, similarity);
break;
case 'forum':
result = generateForumResult(i, similarity);
break;
case 'blog':
result = generateBlogResult(i, similarity);
break;
}
}
// Apply NSFW filter if enabled
if (nsfwFilter.checked && result.nsfw) {
continue;
}
baseResults.push(result);
}
// Sort by similarity (descending)
searchResults = baseResults.sort((a, b) => b.similarity - a.similarity);
}
// Helper functions to generate different types of mock results
function generateSocialMediaResult(index, similarity) {
const types = ['Facebook', 'Instagram', 'Twitter', 'LinkedIn', 'TikTok'];
const type = types[Math.floor(Math.random() * types.length)];
return {
id: `sm-${index}`,
url: `https://${type.toLowerCase()}.com/user${index}`,
image: `https://randomuser.me/api/portraits/${Math.random() > 0.5 ? 'men' : 'women'}/${Math.floor(Math.random() * 100)}.jpg`,
title: `${type} Profile`,
description: `Public profile on ${type}`,
similarity: similarity,
source: type,
date: randomDate(new Date(2020, 0, 1), new Date()),
nsfw: Math.random() < 0.1 // 10% chance of being NSFW
};
}
function generateNewsResult(index, similarity) {
const outlets = ['CNN', 'BBC', 'NY Times', 'Washington Post', 'Fox News'];
const outlet = outlets[Math.floor(Math.random() * outlets.length)];
return {
id: `news-${index}`,
url: `https://${outlet.toLowerCase().replace(' ', '')}.com/article${index}`,
image: `https://randomuser.me/api/portraits/${Math.random() > 0.5 ? 'men' : 'women'}/${Math.floor(Math.random() * 100)}.jpg`,
title: `News Article Mention`,
description: `Appears in a ${outlet} article`,
similarity: similarity,
source: outlet,
date: randomDate(new Date(2020, 0, 1), new Date()),
nsfw: false
};
}
function generatePublicFigureResult(index, similarity) {
const types = ['Politician', 'Celebrity', 'Athlete', 'Business Leader', 'Academic'];
const type = types[Math.floor(Math.random() * types.length)];
return {
id: `public-${index}`,
url: `https://en.wikipedia.org/wiki/public_figure_${index}`,
image: `https://randomuser.me/api/portraits/${Math.random() > 0.5 ? 'men' : 'women'}/${Math.floor(Math.random() * 100)}.jpg`,
title: `${type} Profile`,
description: `Public figure - ${type}`,
similarity: similarity,
source: 'Wikipedia',
date: randomDate(new Date(2010, 0, 1), new Date()),
nsfw: Math.random() < 0.05 // 5% chance of being NSFW
};
}
function generateForumResult(index, similarity) {
const forums = ['Reddit', 'Quora', 'StackExchange', '4chan', 'Medium'];
const forum = forums[Math.floor(Math.random() * forums.length)];
return {
id: `forum-${index}`,
url: `https://${forum.toLowerCase()}.com/post${index}`,
image: `https://randomuser.me/api/portraits/${Math.random() > 0.5 ? 'men' : 'women'}/${Math.floor(Math.random() * 100)}.jpg`,
title: `Forum Post`,
description: `Appears in a ${forum} discussion`,
similarity: similarity,
source: forum,
date: randomDate(new Date(2018, 0, 1), new Date()),
nsfw: forum === '4chan' ? Math.random() < 0.7 : Math.random() < 0.1
};
}
function generateBlogResult(index, similarity) {
const blogs = ['Personal Blog', 'Medium', 'WordPress', 'Blogger', 'Tumblr'];
const blog = blogs[Math.floor(Math.random() * blogs.length)];
return {
id: `blog-${index}`,
url: `https://${blog.toLowerCase().replace(' ', '')}.com/post${index}`,
image: `https://randomuser.me/api/portraits/${Math.random() > 0.5 ? 'men' : 'women'}/${Math.floor(Math.random() * 100)}.jpg`,
title: `Blog Post`,
description: `Appears in a ${blog} article`,
similarity: similarity,
source: blog,
date: randomDate(new Date(2019, 0, 1), new Date()),
nsfw: blog === 'Tumblr' ? Math.random() < 0.3 : Math.random() < 0.1
};
}
function randomDate(start, end) {
const date = new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
return date.toISOString().split('T')[0];
}
// Display results
function displayResults() {
const startIndex = (currentPage - 1) * resultsPerPage;
const endIndex = startIndex + resultsPerPage;
const paginatedResults = searchResults.slice(0, endIndex);
// Update results stats
resultsStats.innerHTML = `
<p>Found ${searchResults.length} potential matches (showing ${paginatedResults.length})</p>
<div class="similarity-meter mt-2 rounded-full"></div>
<div class="flex justify-between text-xs text-gray-500 mt-1">
<span>0%</span>
<span>50%</span>
<span>100%</span>
</div>
`;
// Clear existing results
resultsContainer.innerHTML = '';
// Add new results
paginatedResults.forEach(result => {
const resultCard = document.createElement('div');
resultCard.className = 'result-card bg-white rounded-lg overflow-hidden shadow-md hover:shadow-lg';
// Determine badge color based on similarity
let badgeColor = 'bg-red-500';
if (result.similarity >= 85) badgeColor = 'bg-green-500';
else if (result.similarity >= 70) badgeColor = 'bg-blue-500';
resultCard.innerHTML = `
<a href="${result.url}" target="_blank" class="block">
<div class="relative h-48 overflow-hidden">
<img src="${result.image}" alt="Result" class="w-full h-full object-cover">
<div class="absolute bottom-2 right-2 ${badgeColor} text-white text-xs font-bold px-2 py-1 rounded">
${result.similarity}% match
</div>
${result.nsfw ? '<div class="absolute top-2 left-2 bg-red-500 text-white text-xs font-bold px-2 py-1 rounded">NSFW</div>' : ''}
</div>
<div class="p-4">
<h4 class="font-semibold text-gray-800 mb-1">${result.title}</h4>
<p class="text-sm text-gray-600 mb-2">${result.description}</p>
<div class="flex justify-between text-sm text-gray-500">
<span>${result.source}</span>
<span>${result.date}</span>
</div>
</div>
</a>
`;
resultsContainer.appendChild(resultCard);
});
// Show/hide load more button
if (searchResults.length > endIndex) {
loadMoreBtn.classList.remove('hidden');
} else {
loadMoreBtn.classList.add('hidden');
}
}
// Sort and display results
function sortAndDisplayResults() {
const sortBy = sortResults.value;
switch (sortBy) {
case 'similarity':
searchResults.sort((a, b) => b.similarity - a.similarity);
break;
case 'date':
searchResults.sort((a, b) => new Date(b.date) - new Date(a.date));
break;
case 'source':
searchResults.sort((a, b) => a.source.localeCompare(b.source));
break;
}
currentPage = 1;
displayResults();
}
// Load more results
function loadMoreResults() {
currentPage++;
displayResults();
// Scroll to bottom of new results
setTimeout(() => {
resultsContainer.lastElementChild.scrollIntoView({ behavior: 'smooth' });
}, 100);
}
// In a real implementation, you would have:
// 1. Backend API to store and compare face descriptors
// 2. Database of indexed faces from various sources
// 3. Web scraping/crawling service to gather new images
// 4. User authentication for saved searches
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=bozz723/facecheck" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>