Download index.html from LuHof/removeme: direct link, hf CLI and curl.
- Browser
- Download file 23.8 kB
-
https://huggingface.co/spaces/LuHof/removeme/resolve/main/index.html
- Command line
-
hf download hf://spaces/LuHof/removeme/index.html
-
curl -L -o index.html https://huggingface.co/spaces/LuHof/removeme/resolve/main/index.html
23.8 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Background Remover</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"> | |
| <style> | |
| .dropzone { | |
| border: 2px dashed #cbd5e1; | |
| transition: all 0.3s; | |
| } | |
| .dropzone.active { | |
| border-color: #4f46e5; | |
| background-color: rgba(79, 70, 229, 0.05); | |
| } | |
| .progress-bar { | |
| transition: width 0.3s; | |
| } | |
| .spinner { | |
| animation: spin 1s linear infinite; | |
| } | |
| @keyframes spin { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| .checkerboard-bg { | |
| background-image: | |
| linear-gradient(45deg, #e5e7eb 25%, transparent 25%), | |
| linear-gradient(-45deg, #e5e7eb 25%, transparent 25%), | |
| linear-gradient(45deg, transparent 75%, #e5e7eb 75%), | |
| linear-gradient(-45deg, transparent 75%, #e5e7eb 75%); | |
| background-size: 20px 20px; | |
| background-position: 0 0, 0 10px, 10px -10px, -10px 0px; | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 min-h-screen"> | |
| <div class="container mx-auto px-4 py-8"> | |
| <header class="mb-8"> | |
| <h1 class="text-3xl font-bold text-indigo-600 flex items-center"> | |
| <i class="fas fa-magic mr-2"></i> Background Remover Pro | |
| </h1> | |
| <p class="text-gray-600">Remove backgrounds from multiple images at once</p> | |
| </header> | |
| <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8"> | |
| <div class="border-b border-gray-200"> | |
| <nav class="flex -mb-px"> | |
| <button id="uploadTab" class="py-4 px-6 text-center border-b-2 font-medium text-sm border-indigo-500 text-indigo-600"> | |
| <i class="fas fa-upload mr-2"></i>Upload Images | |
| </button> | |
| <button id="resultsTab" class="py-4 px-6 text-center border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"> | |
| <i class="fas fa-images mr-2"></i>Results | |
| </button> | |
| </nav> | |
| </div> | |
| <div id="uploadTabContent" class="p-6"> | |
| <div class="mb-6"> | |
| <div id="dropzone" class="dropzone rounded-lg bg-white flex flex-col items-center justify-center p-8"> | |
| <div id="uploadContent" class="text-center"> | |
| <div class="mx-auto flex items-center justify-center h-16 w-16 rounded-full bg-indigo-100 mb-4"> | |
| <i class="fas fa-images text-indigo-600 text-2xl"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-gray-700">Drag & drop your photos here</h3> | |
| <p class="mt-1 text-sm text-gray-500">or</p> | |
| <div class="mt-4"> | |
| <label class="cursor-pointer"> | |
| <span class="px-4 py-2 bg-indigo-600 rounded-md text-white font-medium hover:bg-indigo-700"> | |
| Select Files (Max 50) | |
| </span> | |
| <input id="fileInput" type="file" accept="image/*" multiple class="hidden"> | |
| </label> | |
| </div> | |
| <p class="mt-2 text-xs text-gray-500"> | |
| Supports JPG, PNG, WEBP (Max 10MB per file) | |
| </p> | |
| </div> | |
| <div id="processingContent" class="hidden flex-col items-center w-full"> | |
| <div class="w-full bg-gray-200 rounded-full h-2.5 mb-4"> | |
| <div id="batchProgress" class="progress-bar bg-indigo-600 h-2.5 rounded-full" style="width: 0%"></div> | |
| </div> | |
| <div class="flex items-center text-gray-600"> | |
| <div id="spinner" class="spinner w-5 h-5 border-2 border-indigo-500 border-t-transparent rounded-full mr-2"></div> | |
| <span id="progressText">Processing 1 of 50 images...</span> | |
| </div> | |
| <div class="mt-4 p-3 rounded text-sm w-full text-left bg-blue-50 border-l-4 border-blue-400"> | |
| <i class="fas fa-info-circle mr-2 text-blue-500"></i> | |
| <span id="batchNote">Batch processing may take a few minutes. Please keep this tab open.</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="selectedFilesContainer" class="hidden"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-medium text-gray-800">Selected Files (<span id="fileCount">0</span>/50)</h3> | |
| <div class="text-sm text-gray-500"> | |
| <span id="totalSize">0 MB</span> total | |
| </div> | |
| </div> | |
| <div id="selectedFiles" class="space-y-3 max-h-96 overflow-y-auto p-2 border border-gray-200 rounded-md"></div> | |
| <div class="mt-4 flex justify-between"> | |
| <button id="clearAllBtn" class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50"> | |
| <i class="fas fa-trash mr-2"></i> Clear All | |
| </button> | |
| <button id="processBtn" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700"> | |
| <i class="fas fa-play mr-2"></i> Process Batch | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="resultsTabContent" class="hidden p-6"> | |
| <div id="noResultsMessage" class="text-center py-12"> | |
| <div class="mx-auto flex items-center justify-center h-16 w-16 rounded-full bg-gray-100 mb-4"> | |
| <i class="fas fa-images text-gray-400 text-2xl"></i> | |
| </div> | |
| <h3 class="text-lg font-medium text-gray-700">No results yet</h3> | |
| <p class="mt-1 text-sm text-gray-500">Your processed images will appear here</p> | |
| </div> | |
| <div id="resultsWrapper" class="hidden"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-medium text-gray-800">Processed Images (<span id="resultsCount">0</span>)</h3> | |
| <div class="flex space-x-2"> | |
| <button id="downloadAllBtn" class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700"> | |
| <i class="fas fa-download mr-2"></i> Download All | |
| </button> | |
| <button id="clearResultsBtn" class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50"> | |
| <i class="fas fa-trash mr-2"></i> Clear All | |
| </button> | |
| </div> | |
| </div> | |
| <div id="resultsGrid" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4"></div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| document.addEventListener('DOMContentLoaded', function() { | |
| const API_KEY = 'YOUR_API_KEY_HERE'; // Replace with your actual API key | |
| const API_URL = 'https://api.pixelcut.ai/remove-background'; | |
| const MAX_FILES = 50; | |
| const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB | |
| // DOM elements | |
| const fileInput = document.getElementById('fileInput'); | |
| const dropzone = document.getElementById('dropzone'); | |
| const uploadContent = document.getElementById('uploadContent'); | |
| const processingContent = document.getElementById('processingContent'); | |
| const selectedFilesContainer = document.getElementById('selectedFilesContainer'); | |
| const selectedFiles = document.getElementById('selectedFiles'); | |
| const fileCount = document.getElementById('fileCount'); | |
| const totalSize = document.getElementById('totalSize'); | |
| const processBtn = document.getElementById('processBtn'); | |
| const clearAllBtn = document.getElementById('clearAllBtn'); | |
| const uploadTab = document.getElementById('uploadTab'); | |
| const resultsTab = document.getElementById('resultsTab'); | |
| const uploadTabContent = document.getElementById('uploadTabContent'); | |
| const resultsTabContent = document.getElementById('resultsTabContent'); | |
| const resultsWrapper = document.getElementById('resultsWrapper'); | |
| const noResultsMessage = document.getElementById('noResultsMessage'); | |
| const resultsGrid = document.getElementById('resultsGrid'); | |
| const resultsCount = document.getElementById('resultsCount'); | |
| const batchProgress = document.getElementById('batchProgress'); | |
| const progressText = document.getElementById('progressText'); | |
| // State | |
| let selectedFilesList = []; | |
| let processedResults = []; | |
| // Initialize tabs | |
| uploadTab.addEventListener('click', () => switchTab('upload')); | |
| resultsTab.addEventListener('click', () => switchTab('results')); | |
| function switchTab(tab) { | |
| if (tab === 'upload') { | |
| uploadTab.classList.add('border-indigo-500', 'text-indigo-600'); | |
| uploadTab.classList.remove('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300'); | |
| resultsTab.classList.remove('border-indigo-500', 'text-indigo-600'); | |
| resultsTab.classList.add('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300'); | |
| uploadTabContent.classList.remove('hidden'); | |
| resultsTabContent.classList.add('hidden'); | |
| } else { | |
| resultsTab.classList.add('border-indigo-500', 'text-indigo-600'); | |
| resultsTab.classList.remove('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300'); | |
| uploadTab.classList.remove('border-indigo-500', 'text-indigo-600'); | |
| uploadTab.classList.add('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300'); | |
| resultsTabContent.classList.remove('hidden'); | |
| uploadTabContent.classList.add('hidden'); | |
| updateResultsView(); | |
| } | |
| } | |
| // Drag and drop functionality | |
| ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { | |
| dropzone.addEventListener(eventName, preventDefaults, false); | |
| document.body.addEventListener(eventName, preventDefaults, false); | |
| }); | |
| function preventDefaults(e) { | |
| e.preventDefault(); | |
| e.stopPropagation(); | |
| } | |
| ['dragenter', 'dragover'].forEach(eventName => { | |
| dropzone.addEventListener(eventName, highlight, false); | |
| }); | |
| ['dragleave', 'drop'].forEach(eventName => { | |
| dropzone.addEventListener(eventName, unhighlight, false); | |
| }); | |
| function highlight() { | |
| dropzone.classList.add('active'); | |
| } | |
| function unhighlight() { | |
| dropzone.classList.remove('active'); | |
| } | |
| dropzone.addEventListener('drop', handleDrop, false); | |
| function handleDrop(e) { | |
| const files = e.dataTransfer.files; | |
| if (files.length > 0) { | |
| handleFiles(files); | |
| } | |
| } | |
| // File input change handler | |
| fileInput.addEventListener('change', function() { | |
| if (this.files.length > 0) { | |
| handleFiles(this.files); | |
| } | |
| }); | |
| function handleFiles(files) { | |
| const validFiles = Array.from(files).filter(file => { | |
| return file.type.match('image.*') && file.size <= MAX_FILE_SIZE; | |
| }).slice(0, MAX_FILES - selectedFilesList.length); | |
| const invalidFiles = Array.from(files).filter(file => { | |
| return !file.type.match('image.*') || file.size > MAX_FILE_SIZE; | |
| }); | |
| if (invalidFiles.length > 0) { | |
| alert(`${invalidFiles.length} file(s) were ignored. Only JPG/PNG/WEBP files under 10MB are supported.`); | |
| } | |
| if (validFiles.length === 0) return; | |
| selectedFilesList = [...selectedFilesList, ...validFiles]; | |
| updateSelectedFilesView(); | |
| updateTotalSize(); | |
| if (selectedFilesList.length > 0) { | |
| selectedFilesContainer.classList.remove('hidden'); | |
| } | |
| fileCount.textContent = selectedFilesList.length; | |
| if (selectedFilesList.length >= MAX_FILES) { | |
| fileInput.disabled = true; | |
| } | |
| } | |
| function updateTotalSize() { | |
| const totalBytes = selectedFilesList.reduce((sum, file) => sum + file.size, 0); | |
| totalSize.textContent = formatFileSize(totalBytes); | |
| } | |
| function updateSelectedFilesView() { | |
| selectedFiles.innerHTML = ''; | |
| selectedFilesList.forEach((file, index) => { | |
| const fileElement = document.createElement('div'); | |
| fileElement.className = 'flex items-center justify-between p-2 bg-gray-50 rounded'; | |
| const previewContainer = document.createElement('div'); | |
| previewContainer.className = 'flex items-center flex-grow'; | |
| // Create thumbnail preview | |
| const thumbnailContainer = document.createElement('div'); | |
| thumbnailContainer.className = 'w-12 h-12 mr-3 flex-shrink-0'; | |
| const thumbnail = document.createElement('div'); | |
| thumbnail.className = 'w-full h-full bg-gray-200 rounded overflow-hidden'; | |
| const img = document.createElement('img'); | |
| img.className = 'w-full h-full object-cover'; | |
| const fileReader = new FileReader(); | |
| fileReader.onload = function(e) { | |
| img.src = e.target.result; | |
| }; | |
| fileReader.readAsDataURL(file); | |
| thumbnail.appendChild(img); | |
| thumbnailContainer.appendChild(thumbnail); | |
| // File info | |
| const fileInfo = document.createElement('div'); | |
| fileInfo.className = 'truncate'; | |
| const fileName = document.createElement('div'); | |
| fileName.className = 'text-sm font-medium text-gray-800 truncate'; | |
| fileName.textContent = file.name.length > 20 ? file.name.substring(0, 20) + '...' : file.name; | |
| fileName.title = file.name; | |
| const fileSize = document.createElement('div'); | |
| fileSize.className = 'text-xs text-gray-500'; | |
| fileSize.textContent = formatFileSize(file.size); | |
| fileInfo.appendChild(fileName); | |
| fileInfo.appendChild(fileSize); | |
| // Remove button | |
| const removeBtn = document.createElement('button'); | |
| removeBtn.className = 'ml-2 text-gray-400 hover:text-red-500'; | |
| removeBtn.innerHTML = '<i class="fas fa-times"></i>'; | |
| removeBtn.onclick = () => removeFile(index); | |
| previewContainer.appendChild(thumbnailContainer); | |
| previewContainer.appendChild(fileInfo); | |
| fileElement.appendChild(previewContainer); | |
| fileElement.appendChild(removeBtn); | |
| selectedFiles.appendChild(fileElement); | |
| }); | |
| } | |
| function formatFileSize(bytes) { | |
| if (bytes === 0) return '0 Bytes'; | |
| const k = 1024; | |
| const sizes = ['Bytes', 'KB', 'MB']; | |
| const i = Math.floor(Math.log(bytes) / Math.log(k)); | |
| return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]; | |
| } | |
| function removeFile(index) { | |
| selectedFilesList.splice(index, 1); | |
| updateSelectedFilesView(); | |
| fileCount.textContent = selectedFilesList.length; | |
| updateTotalSize(); | |
| if (selectedFilesList.length === 0) { | |
| selectedFilesContainer.classList.add('hidden'); | |
| } | |
| if (selectedFilesList.length < MAX_FILES) { | |
| fileInput.disabled = false; | |
| } | |
| } | |
| clearAllBtn.addEventListener('click', clearAllFiles); | |
| function clearAllFiles() { | |
| selectedFilesList = []; | |
| selectedFiles.innerHTML = ''; | |
| selectedFilesContainer.classList.add('hidden'); | |
| fileCount.textContent = '0'; | |
| totalSize.textContent = '0 MB'; | |
| fileInput.value = ''; | |
| fileInput.disabled = false; | |
| } | |
| processBtn.addEventListener('click', processFiles); | |
| async function processFiles() { | |
| if (selectedFilesList.length === 0) { | |
| alert('Please select files to process'); | |
| return; | |
| } | |
| uploadContent.classList.add('hidden'); | |
| processingContent.classList.remove('hidden'); | |
| const totalFiles = selectedFilesList.length; | |
| let completedFiles = 0; | |
| // For DEMO purposes - simulate processing | |
| for (let i = 0; i < totalFiles; i++) { | |
| setTimeout(() => { | |
| completedFiles++; | |
| const progress = Math.round((completedFiles / totalFiles) * 100); | |
| batchProgress.style.width = `${progress}%`; | |
| progressText.textContent = `Processing ${completedFiles} of ${totalFiles} images...`; | |
| if (completedFiles === totalFiles) { | |
| // Simulate API response by creating dummy processed files | |
| selectedFilesList.forEach(file => { | |
| processedResults.push({ | |
| original: file, | |
| processed: new Blob([], { type: 'image/png' }) // Dummy blob for demo | |
| }); | |
| }); | |
| progressText.textContent = 'Processing complete!'; | |
| setTimeout(() => { | |
| processingContent.classList.add('hidden'); | |
| uploadContent.classList.remove('hidden'); | |
| clearAllFiles(); | |
| switchTab('results'); | |
| }, 1000); | |
| } | |
| }, i * 500); | |
| } | |
| /* | |
| // Actual API integration would look like this: | |
| try { | |
| const response = await fetch(API_URL, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| 'Accept': 'application/json', | |
| 'X-API-KEY': API_KEY | |
| }, | |
| body: JSON.stringify({ | |
| image_url: "URL_TO_YOUR_IMAGE", | |
| format: "png" | |
| }) | |
| }); | |
| if (!response.ok) throw new Error('API error'); | |
| const data = await response.json(); | |
| // Process response data | |
| } catch (error) { | |
| console.error('Error:', error); | |
| } | |
| */ | |
| } | |
| function updateResultsView() { | |
| if (processedResults.length === 0) { | |
| noResultsMessage.classList.remove('hidden'); | |
| resultsWrapper.classList.add('hidden'); | |
| return; | |
| } | |
| noResultsMessage.classList.add('hidden'); | |
| resultsWrapper.classList.remove('hidden'); | |
| resultsCount.textContent = processedResults.length; | |
| resultsGrid.innerHTML = ''; | |
| processedResults.forEach((result, index) => { | |
| const resultElement = document.createElement('div'); | |
| resultElement.className = 'bg-white rounded-lg shadow-sm overflow-hidden border border-gray-200 hover:shadow-md'; | |
| const thumbnail = document.createElement('div'); | |
| thumbnail.className = 'thumbnail checkerboard-bg'; | |
| thumbnail.style.paddingBottom = '100%'; | |
| thumbnail.style.position = 'relative'; | |
| const preview = document.createElement('div'); | |
| preview.className = 'absolute inset-0 flex items-center justify-center'; | |
| // In a real implementation, we'd show the processed image here | |
| const imgPlace | |
| </html> |