ml app that can detect an image using a web cam, and from the results it can find related images and it can put them in a dynamic collage
Browse files- README.md +7 -4
- index.html +264 -18
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
title: Visionary Collage Creator
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: Visionary Collage Creator
|
| 3 |
+
colorFrom: gray
|
| 4 |
+
colorTo: green
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://deepsite.hf.co).
|
index.html
CHANGED
|
@@ -1,19 +1,265 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Visionary Collage Creator</title>
|
| 7 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 10 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 11 |
+
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
|
| 12 |
+
<style>
|
| 13 |
+
.collage-item {
|
| 14 |
+
transition: all 0.3s ease;
|
| 15 |
+
}
|
| 16 |
+
.collage-item:hover {
|
| 17 |
+
transform: scale(1.05);
|
| 18 |
+
z-index: 10;
|
| 19 |
+
}
|
| 20 |
+
.camera-container {
|
| 21 |
+
border-radius: 12px;
|
| 22 |
+
overflow: hidden;
|
| 23 |
+
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
| 24 |
+
}
|
| 25 |
+
.collage-container {
|
| 26 |
+
min-height: 400px;
|
| 27 |
+
background: rgba(255, 255, 255, 0.1);
|
| 28 |
+
backdrop-filter: blur(10px);
|
| 29 |
+
border-radius: 16px;
|
| 30 |
+
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
|
| 31 |
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
| 32 |
+
}
|
| 33 |
+
.pulse {
|
| 34 |
+
animation: pulse 2s infinite;
|
| 35 |
+
}
|
| 36 |
+
@keyframes pulse {
|
| 37 |
+
0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
|
| 38 |
+
70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
|
| 39 |
+
100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
|
| 40 |
+
}
|
| 41 |
+
</style>
|
| 42 |
+
</head>
|
| 43 |
+
<body class="bg-gradient-to-br from-gray-900 to-blue-900 min-h-screen text-white">
|
| 44 |
+
<!-- Background Animation -->
|
| 45 |
+
<div id="vanta-bg" class="fixed top-0 left-0 w-full h-full -z-10"></div>
|
| 46 |
+
|
| 47 |
+
<!-- Header -->
|
| 48 |
+
<header class="container mx-auto px-4 py-8">
|
| 49 |
+
<div class="flex flex-col md:flex-row justify-between items-center">
|
| 50 |
+
<div class="flex items-center mb-6 md:mb-0">
|
| 51 |
+
<i data-feather="camera" class="mr-3 text-blue-400" size="32"></i>
|
| 52 |
+
<h1 class="text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-blue-400 to-purple-500">
|
| 53 |
+
Visionary Collage Creator
|
| 54 |
+
</h1>
|
| 55 |
+
</div>
|
| 56 |
+
<div class="flex space-x-4">
|
| 57 |
+
<button id="start-camera" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-full flex items-center transition-all">
|
| 58 |
+
<i data-feather="video" class="mr-2"></i> Start Camera
|
| 59 |
+
</button>
|
| 60 |
+
<button id="capture-btn" class="bg-purple-600 hover:bg-purple-700 text-white px-6 py-2 rounded-full flex items-center transition-all pulse">
|
| 61 |
+
<i data-feather="camera" class="mr-2"></i> Capture
|
| 62 |
+
</button>
|
| 63 |
+
</div>
|
| 64 |
+
</div>
|
| 65 |
+
</header>
|
| 66 |
+
|
| 67 |
+
<main class="container mx-auto px-4 py-8">
|
| 68 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
| 69 |
+
<!-- Camera Section -->
|
| 70 |
+
<div class="camera-container bg-black/30 p-6 rounded-2xl">
|
| 71 |
+
<h2 class="text-xl font-semibold mb-4 flex items-center">
|
| 72 |
+
<i data-feather="eye" class="mr-2 text-blue-400"></i> Camera View
|
| 73 |
+
</h2>
|
| 74 |
+
<div class="relative">
|
| 75 |
+
<video id="video" class="w-full rounded-lg bg-gray-800" autoplay playsinline></video>
|
| 76 |
+
<div id="loading" class="absolute inset-0 bg-black/70 flex items-center justify-center rounded-lg hidden">
|
| 77 |
+
<div class="text-center">
|
| 78 |
+
<i data-feather="loader" class="animate-spin text-blue-400 mb-2" size="32"></i>
|
| 79 |
+
<p>Analyzing image...</p>
|
| 80 |
+
</div>
|
| 81 |
+
</div>
|
| 82 |
+
</div>
|
| 83 |
+
<div class="mt-4">
|
| 84 |
+
<div class="flex items-center mb-2">
|
| 85 |
+
<i data-feather="tag" class="mr-2 text-green-400"></i>
|
| 86 |
+
<p id="prediction-text" class="font-medium">Point your camera at an object to detect it</p>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<!-- Collage Section -->
|
| 92 |
+
<div class="collage-container p-6 rounded-2xl">
|
| 93 |
+
<div class="flex justify-between items-center mb-4">
|
| 94 |
+
<h2 class="text-xl font-semibold flex items-center">
|
| 95 |
+
<i data-feather="grid" class="mr-2 text-purple-400"></i> Dynamic Collage
|
| 96 |
+
</h2>
|
| 97 |
+
<button id="clear-collage" class="text-sm bg-red-600 hover:bg-red-700 px-3 py-1 rounded-full flex items-center">
|
| 98 |
+
<i data-feather="trash-2" class="mr-1" size="16"></i> Clear
|
| 99 |
+
</button>
|
| 100 |
+
</div>
|
| 101 |
+
<div id="collage" class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4">
|
| 102 |
+
<div class="col-span-full text-center py-12 text-gray-400">
|
| 103 |
+
<i data-feather="image" class="mb-2" size="48"></i>
|
| 104 |
+
<p>Capture an image to start building your collage</p>
|
| 105 |
+
</div>
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<!-- How it works section -->
|
| 111 |
+
<section class="mt-16 bg-black/20 backdrop-blur-sm rounded-2xl p-8">
|
| 112 |
+
<h2 class="text-2xl font-bold text-center mb-8">How It Works</h2>
|
| 113 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
|
| 114 |
+
<div class="text-center p-6 bg-white/5 rounded-xl">
|
| 115 |
+
<div class="w-16 h-16 bg-blue-500 rounded-full flex items-center justify-center mx-auto mb-4">
|
| 116 |
+
<i data-feather="camera" size="24"></i>
|
| 117 |
+
</div>
|
| 118 |
+
<h3 class="text-xl font-semibold mb-2">Capture Image</h3>
|
| 119 |
+
<p class="text-gray-300">Point your camera at any object and capture an image with one click</p>
|
| 120 |
+
</div>
|
| 121 |
+
<div class="text-center p-6 bg-white/5 rounded-xl">
|
| 122 |
+
<div class="w-16 h-16 bg-purple-500 rounded-full flex items-center justify-center mx-auto mb-4">
|
| 123 |
+
<i data-feather="cpu" size="24"></i>
|
| 124 |
+
</div>
|
| 125 |
+
<h3 class="text-xl font-semibold mb-2">AI Detection</h3>
|
| 126 |
+
<p class="text-gray-300">Our ML model identifies the object and finds related images</p>
|
| 127 |
+
</div>
|
| 128 |
+
<div class="text-center p-6 bg-white/5 rounded-xl">
|
| 129 |
+
<div class="w-16 h-16 bg-green-500 rounded-full flex items-center justify-center mx-auto mb-4">
|
| 130 |
+
<i data-feather="layout" size="24"></i>
|
| 131 |
+
</div>
|
| 132 |
+
<h3 class="text-xl font-semibold mb-2">Dynamic Collage</h3>
|
| 133 |
+
<p class="text-gray-300">Related images are automatically added to your personalized collage</p>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
</section>
|
| 137 |
+
</main>
|
| 138 |
+
|
| 139 |
+
<footer class="container mx-auto px-4 py-8 mt-12 text-center text-gray-400">
|
| 140 |
+
<p>Visionary Collage Creator © 2023 | Powered by Machine Learning</p>
|
| 141 |
+
</footer>
|
| 142 |
+
|
| 143 |
+
<script>
|
| 144 |
+
// Initialize Feather Icons
|
| 145 |
+
feather.replace();
|
| 146 |
+
|
| 147 |
+
// Initialize Vanta.js background
|
| 148 |
+
VANTA.GLOBE({
|
| 149 |
+
el: "#vanta-bg",
|
| 150 |
+
mouseControls: true,
|
| 151 |
+
touchControls: true,
|
| 152 |
+
gyroControls: false,
|
| 153 |
+
minHeight: 200.00,
|
| 154 |
+
minWidth: 200.00,
|
| 155 |
+
scale: 1.00,
|
| 156 |
+
scaleMobile: 1.00,
|
| 157 |
+
color: 0x3b82f6,
|
| 158 |
+
color2: 0x8b5cf6,
|
| 159 |
+
backgroundColor: 0x0f172a
|
| 160 |
+
});
|
| 161 |
+
|
| 162 |
+
// DOM Elements
|
| 163 |
+
const video = document.getElementById('video');
|
| 164 |
+
const startCameraBtn = document.getElementById('start-camera');
|
| 165 |
+
const captureBtn = document.getElementById('capture-btn');
|
| 166 |
+
const predictionText = document.getElementById('prediction-text');
|
| 167 |
+
const collage = document.getElementById('collage');
|
| 168 |
+
const loading = document.getElementById('loading');
|
| 169 |
+
const clearCollageBtn = document.getElementById('clear-collage');
|
| 170 |
+
|
| 171 |
+
// Camera setup
|
| 172 |
+
let stream = null;
|
| 173 |
+
|
| 174 |
+
startCameraBtn.addEventListener('click', async () => {
|
| 175 |
+
try {
|
| 176 |
+
stream = await navigator.mediaDevices.getUserMedia({ video: true });
|
| 177 |
+
video.srcObject = stream;
|
| 178 |
+
startCameraBtn.innerHTML = '<i data-feather="video-off" class="mr-2"></i> Stop Camera';
|
| 179 |
+
startCameraBtn.classList.remove('bg-blue-600', 'hover:bg-blue-700');
|
| 180 |
+
startCameraBtn.classList.add('bg-red-600', 'hover:bg-red-700');
|
| 181 |
+
feather.replace();
|
| 182 |
+
} catch (err) {
|
| 183 |
+
console.error("Error accessing camera:", err);
|
| 184 |
+
predictionText.textContent = "Error accessing camera. Please check permissions.";
|
| 185 |
+
predictionText.classList.add('text-red-400');
|
| 186 |
+
}
|
| 187 |
+
});
|
| 188 |
+
|
| 189 |
+
startCameraBtn.addEventListener('click', () => {
|
| 190 |
+
if (stream) {
|
| 191 |
+
stream.getTracks().forEach(track => track.stop());
|
| 192 |
+
stream = null;
|
| 193 |
+
video.srcObject = null;
|
| 194 |
+
startCameraBtn.innerHTML = '<i data-feather="video" class="mr-2"></i> Start Camera';
|
| 195 |
+
startCameraBtn.classList.remove('bg-red-600', 'hover:bg-red-700');
|
| 196 |
+
startCameraBtn.classList.add('bg-blue-600', 'hover:bg-blue-700');
|
| 197 |
+
feather.replace();
|
| 198 |
+
}
|
| 199 |
+
});
|
| 200 |
+
|
| 201 |
+
// Capture image and process
|
| 202 |
+
captureBtn.addEventListener('click', () => {
|
| 203 |
+
if (!stream) {
|
| 204 |
+
predictionText.textContent = "Please start the camera first";
|
| 205 |
+
predictionText.classList.add('text-yellow-400');
|
| 206 |
+
return;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
loading.classList.remove('hidden');
|
| 210 |
+
captureBtn.classList.add('opacity-50', 'cursor-not-allowed');
|
| 211 |
+
|
| 212 |
+
// Simulate ML processing delay
|
| 213 |
+
setTimeout(() => {
|
| 214 |
+
// In a real app, this would be replaced with actual ML detection
|
| 215 |
+
const objects = ['cat', 'dog', 'car', 'mountain', 'technology', 'nature', 'people', 'food'];
|
| 216 |
+
const detectedObject = objects[Math.floor(Math.random() * objects.length)];
|
| 217 |
+
|
| 218 |
+
predictionText.textContent = `Detected: ${detectedObject}`;
|
| 219 |
+
predictionText.classList.remove('text-yellow-400', 'text-red-400');
|
| 220 |
+
predictionText.classList.add('text-green-400');
|
| 221 |
+
|
| 222 |
+
// Add to collage
|
| 223 |
+
addToCollage(detectedObject);
|
| 224 |
+
|
| 225 |
+
loading.classList.add('hidden');
|
| 226 |
+
captureBtn.classList.remove('opacity-50', 'cursor-not-allowed');
|
| 227 |
+
}, 1500);
|
| 228 |
+
});
|
| 229 |
+
|
| 230 |
+
// Add image to collage
|
| 231 |
+
function addToCollage(object) {
|
| 232 |
+
// Remove placeholder if it exists
|
| 233 |
+
if (collage.children.length === 1 && collage.children[0].classList.contains('col-span-full')) {
|
| 234 |
+
collage.innerHTML = '';
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
// Create new collage item
|
| 238 |
+
const collageItem = document.createElement('div');
|
| 239 |
+
collageItem.className = 'collage-item rounded-lg overflow-hidden shadow-lg transform transition-transform hover:scale-105';
|
| 240 |
+
|
| 241 |
+
// Generate random image based on object
|
| 242 |
+
const seed = Math.floor(Math.random() * 1000);
|
| 243 |
+
const imageUrl = `http://static.photos/${object}/320x240/${seed}`;
|
| 244 |
+
|
| 245 |
+
collageItem.innerHTML = `
|
| 246 |
+
<img src="${imageUrl}" alt="${object}" class="w-full h-32 object-cover">
|
| 247 |
+
<div class="p-2 bg-black/50 text-sm truncate">${object}</div>
|
| 248 |
+
`;
|
| 249 |
+
|
| 250 |
+
collage.appendChild(collageItem);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
// Clear collage
|
| 254 |
+
clearCollageBtn.addEventListener('click', () => {
|
| 255 |
+
collage.innerHTML = `
|
| 256 |
+
<div class="col-span-full text-center py-12 text-gray-400">
|
| 257 |
+
<i data-feather="image" class="mb-2" size="48"></i>
|
| 258 |
+
<p>Capture an image to start building your collage</p>
|
| 259 |
+
</div>
|
| 260 |
+
`;
|
| 261 |
+
feather.replace();
|
| 262 |
+
});
|
| 263 |
+
</script>
|
| 264 |
+
</body>
|
| 265 |
</html>
|