facefusion-studio / index.html
RobX1234's picture
ok cancel this and only one page website that swaps face. one box ask for source image and one box asks for target image. https://huggingface.co/spaces/qx3626/nsfw-face-swap
649164a verified
Raw History Blame Contribute Delete
7.06 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NSFW Face Swap</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
.dropzone {
border: 2px dashed #9ca3af;
transition: all 0.3s ease;
}
.dropzone.active {
border-color: #3b82f6;
background: rgba(59, 130, 246, 0.05);
}
.gradient-bg {
background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<div class="container mx-auto px-4 py-12">
<h1 class="text-3xl font-bold text-center mb-8 text-gray-800">NSFW Face Swap</h1>
<div class="grid grid-cols-1 md:grid-cols-2 gap-8 max-w-4xl mx-auto">
<!-- Source Image -->
<div class="dropzone h-64 rounded-lg flex flex-col items-center justify-center relative overflow-hidden">
<div class="text-center p-4">
<svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 mx-auto mb-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
</svg>
<h3 class="text-lg font-medium text-gray-700">Source Face</h3>
<p class="text-gray-500 text-sm mt-1">Upload the face to swap from</p>
<input type="file" id="source-file" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer" accept="image/*">
</div>
<img id="source-preview" class="absolute inset-0 w-full h-full object-cover hidden" src="" alt="Source preview">
</div>
<!-- Target Image -->
<div class="dropzone h-64 rounded-lg flex flex-col items-center justify-center relative overflow-hidden">
<div class="text-center p-4">
<svg xmlns="http://www.w3.org/2000/svg" class="h-12 w-12 mx-auto mb-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
</svg>
<h3 class="text-lg font-medium text-gray-700">Target Face</h3>
<p class="text-gray-500 text-sm mt-1">Upload the face to swap onto</p>
<input type="file" id="target-file" class="absolute inset-0 w-full h-full opacity-0 cursor-pointer" accept="image/*">
</div>
<img id="target-preview" class="absolute inset-0 w-full h-full object-cover hidden" src="" alt="Target preview">
</div>
</div>
<!-- Result Preview -->
<div class="mt-8 flex flex-col items-center">
<div id="result-container" class="w-full max-w-md h-64 bg-gray-100 rounded-lg flex items-center justify-center hidden">
<img id="result-preview" class="w-full h-full object-contain" src="" alt="Result preview">
</div>
<button id="swap-button" class="mt-6 px-8 py-3 rounded-full gradient-bg text-white font-medium hover:opacity-90 transition">
Swap Faces
</button>
</div>
<!-- NSFW Warning -->
<div class="mt-8 text-center text-sm text-gray-500">
<p>Warning: This tool supports NSFW content. Use responsibly.</p>
</div>
</div>
<script>
// Handle file uploads and previews
const sourceFile = document.getElementById('source-file');
const targetFile = document.getElementById('target-file');
const sourcePreview = document.getElementById('source-preview');
const targetPreview = document.getElementById('target-preview');
const resultContainer = document.getElementById('result-container');
const resultPreview = document.getElementById('result-preview');
const swapButton = document.getElementById('swap-button');
// Setup dropzone interactions for both upload areas
const setupDropzone = (dropzone, input, preview) => {
['dragenter', 'dragover'].forEach(eventName => {
dropzone.addEventListener(eventName, () => {
dropzone.classList.add('active');
});
});
['dragleave', 'drop'].forEach(eventName => {
dropzone.addEventListener(eventName, () => {
dropzone.classList.remove('active');
});
});
input.addEventListener('change', (e) => {
if (e.target.files.length) {
const file = e.target.files[0];
const reader = new FileReader();
reader.onload = (event) => {
preview.src = event.target.result;
preview.classList.remove('hidden');
dropzone.querySelector('div').classList.add('hidden');
// Enable swap button if both images are loaded
if (sourcePreview.src && targetPreview.src) {
swapButton.disabled = false;
}
};
reader.readAsDataURL(file);
}
});
};
// Initialize both dropzones
setupDropzone(
document.querySelectorAll('.dropzone')[0],
sourceFile,
sourcePreview
);
setupDropzone(
document.querySelectorAll('.dropzone')[1],
targetFile,
targetPreview
);
// Handle face swap
swapButton.addEventListener('click', async () => {
if (!sourcePreview.src || !targetPreview.src) {
alert('Please upload both source and target images first');
return;
}
swapButton.disabled = true;
swapButton.textContent = 'Processing...';
// In a real implementation, you would send the images to your API here
// This is just a simulation
setTimeout(() => {
// For demo purposes, we'll just show the target image as result
resultPreview.src = targetPreview.src;
resultContainer.classList.remove('hidden');
swapButton.disabled = false;
swapButton.textContent = 'Swap Faces';
// Scroll to result
resultContainer.scrollIntoView({ behavior: 'smooth' });
}, 2000);
});
</script>
</body>
</html>