Spaces:
Running
Running
biraz daha estetik yapabilir misin tema açısından - Initial Deployment
Browse files- README.md +7 -5
- index.html +275 -19
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: catish-tester
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,275 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>AI Image Classifier</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest/dist/tf.min.js"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/@teachablemachine/image@latest/dist/teachablemachine-image.min.js"></script>
|
| 10 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 11 |
+
<style>
|
| 12 |
+
.webcam-box {
|
| 13 |
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
|
| 14 |
+
border-radius: 1.5rem;
|
| 15 |
+
overflow: hidden;
|
| 16 |
+
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
| 17 |
+
will-change: transform;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.webcam-box:hover {
|
| 21 |
+
transform: translateY(-2px);
|
| 22 |
+
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
.prediction-bar {
|
| 26 |
+
transition: width 0.5s ease;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
@keyframes pulse {
|
| 30 |
+
0%, 100% {
|
| 31 |
+
opacity: 1;
|
| 32 |
+
}
|
| 33 |
+
50% {
|
| 34 |
+
opacity: 0.5;
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.pulse-animation {
|
| 39 |
+
animation: pulse 2s infinite;
|
| 40 |
+
}
|
| 41 |
+
</style>
|
| 42 |
+
</head>
|
| 43 |
+
<body class="bg-gradient-to-br from-indigo-50 via-purple-50 to-pink-50 min-h-screen backdrop-blur-sm">
|
| 44 |
+
<div class="container mx-auto px-4 py-8">
|
| 45 |
+
<!-- Header -->
|
| 46 |
+
<header class="text-center mb-16">
|
| 47 |
+
<h1 class="text-5xl md:text-6xl font-bold bg-gradient-to-r from-indigo-600 to-pink-500 bg-clip-text text-transparent mb-4">
|
| 48 |
+
<i class="fas fa-robot mr-3"></i>
|
| 49 |
+
AI Image Classifier
|
| 50 |
+
</h1>
|
| 51 |
+
<p class="text-xl text-indigo-600/80 max-w-2xl mx-auto leading-relaxed">
|
| 52 |
+
A real-time image classification system powered by <span class="font-medium">Teachable Machine</span> and <span class="font-medium">TensorFlow.js</span>
|
| 53 |
+
</p>
|
| 54 |
+
<div class="mt-6 h-1 w-24 bg-gradient-to-r from-indigo-400 to-pink-400 rounded-full mx-auto"></div>
|
| 55 |
+
</header>
|
| 56 |
+
|
| 57 |
+
<!-- Main Content -->
|
| 58 |
+
<div class="flex flex-col lg:flex-row gap-8 items-center lg:items-start justify-center">
|
| 59 |
+
<!-- Webcam Container -->
|
| 60 |
+
<div class="flex-1 max-w-md">
|
| 61 |
+
<div class="bg-white/90 p-6 rounded-2xl shadow-xl webcam-box border border-white backdrop-blur-sm">
|
| 62 |
+
<h2 class="text-xl font-semibold text-indigo-800 mb-4 flex items-center">
|
| 63 |
+
<i class="fas fa-camera mr-2"></i>
|
| 64 |
+
Live Camera Feed
|
| 65 |
+
</h2>
|
| 66 |
+
<div id="webcam-container" class="relative bg-gray-200 rounded-lg overflow-hidden w-full aspect-square flex items-center justify-center">
|
| 67 |
+
<div class="text-center p-4">
|
| 68 |
+
<i class="fas fa-camera text-4xl text-gray-400 mb-2"></i>
|
| 69 |
+
<p class="text-gray-500">Camera feed will appear here</p>
|
| 70 |
+
</div>
|
| 71 |
+
</div>
|
| 72 |
+
<div class="mt-4 flex justify-center">
|
| 73 |
+
<button id="start-btn" onclick="init()" class="bg-gradient-to-r from-indigo-500 to-indigo-600 hover:from-indigo-600 hover:to-indigo-700 text-white font-medium py-3 px-8 rounded-xl flex items-center transition-all duration-300 transform hover:scale-[1.02] active:scale-95 shadow-md hover:shadow-lg">
|
| 74 |
+
<i class="fas fa-play mr-2"></i>
|
| 75 |
+
Start Classification
|
| 76 |
+
</button>
|
| 77 |
+
</div>
|
| 78 |
+
</div>
|
| 79 |
+
</div>
|
| 80 |
+
|
| 81 |
+
<!-- Predictions Container -->
|
| 82 |
+
<div class="flex-1 max-w-md">
|
| 83 |
+
<div class="bg-white p-6 rounded-xl shadow-lg h-full">
|
| 84 |
+
<h2 class="text-xl font-semibold text-indigo-800 mb-4 flex items-center">
|
| 85 |
+
<i class="fas fa-chart-bar mr-2"></i>
|
| 86 |
+
Prediction Results
|
| 87 |
+
</h2>
|
| 88 |
+
<div id="label-container" class="space-y-4">
|
| 89 |
+
<div class="text-center py-8">
|
| 90 |
+
<i class="fas fa-brain text-4xl text-gray-300 mb-2"></i>
|
| 91 |
+
<p class="text-gray-500">Predictions will appear here</p>
|
| 92 |
+
<p class="text-sm text-gray-400 mt-2">Start the classifier to see real-time results</p>
|
| 93 |
+
</div>
|
| 94 |
+
</div>
|
| 95 |
+
|
| 96 |
+
<div class="mt-6 bg-blue-50 p-4 rounded-lg">
|
| 97 |
+
<h3 class="font-medium text-blue-800 mb-2 flex items-center">
|
| 98 |
+
<i class="fas fa-info-circle mr-2"></i>
|
| 99 |
+
How it works
|
| 100 |
+
</h3>
|
| 101 |
+
<p class="text-sm text-blue-700">
|
| 102 |
+
This AI model analyzes images from your webcam and predicts what it sees based on its training.
|
| 103 |
+
The confidence scores show how certain the model is about each prediction.
|
| 104 |
+
</p>
|
| 105 |
+
</div>
|
| 106 |
+
</div>
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<!-- Footer -->
|
| 111 |
+
<footer class="mt-20 text-center text-gray-500/80 text-sm">
|
| 112 |
+
<div class="inline-flex items-center space-x-4">
|
| 113 |
+
<span>Powered by Teachable Machine</span>
|
| 114 |
+
<span class="w-1 h-1 bg-gray-400 rounded-full"></span>
|
| 115 |
+
<span>TensorFlow.js</span>
|
| 116 |
+
<span class="w-1 h-1 bg-gray-400 rounded-full"></span>
|
| 117 |
+
<span>© 2023 AI Image Classifier</span>
|
| 118 |
+
</div>
|
| 119 |
+
</footer>
|
| 120 |
+
</div>
|
| 121 |
+
|
| 122 |
+
<script type="text/javascript">
|
| 123 |
+
// the link to your model provided by Teachable Machine export panel
|
| 124 |
+
const URL = "https://teachablemachine.withgoogle.com/models/4_uQTHOX7L/";
|
| 125 |
+
|
| 126 |
+
let model, webcam, labelContainer, maxPredictions;
|
| 127 |
+
|
| 128 |
+
// Load the image model and setup the webcam
|
| 129 |
+
async function init() {
|
| 130 |
+
try {
|
| 131 |
+
// Change button state
|
| 132 |
+
const startBtn = document.getElementById('start-btn');
|
| 133 |
+
startBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Loading...';
|
| 134 |
+
startBtn.classList.remove('bg-indigo-600', 'hover:bg-indigo-700');
|
| 135 |
+
startBtn.classList.add('bg-gray-500', 'cursor-not-allowed');
|
| 136 |
+
startBtn.disabled = true;
|
| 137 |
+
|
| 138 |
+
const modelURL = URL + "model.json";
|
| 139 |
+
const metadataURL = URL + "metadata.json";
|
| 140 |
+
|
| 141 |
+
// load the model and metadata
|
| 142 |
+
model = await tmImage.load(modelURL, metadataURL);
|
| 143 |
+
maxPredictions = model.getTotalClasses();
|
| 144 |
+
|
| 145 |
+
// Setup webcam
|
| 146 |
+
const flip = true; // whether to flip the webcam
|
| 147 |
+
webcam = new tmImage.Webcam(400, 400, flip); // width, height, flip
|
| 148 |
+
await webcam.setup(); // request access to the webcam
|
| 149 |
+
await webcam.play();
|
| 150 |
+
|
| 151 |
+
// Clear webcam container and add canvas
|
| 152 |
+
const webcamContainer = document.getElementById('webcam-container');
|
| 153 |
+
webcamContainer.innerHTML = '';
|
| 154 |
+
webcamContainer.appendChild(webcam.canvas);
|
| 155 |
+
|
| 156 |
+
// Setup label container
|
| 157 |
+
labelContainer = document.getElementById('label-container');
|
| 158 |
+
labelContainer.innerHTML = '';
|
| 159 |
+
|
| 160 |
+
// Update button state
|
| 161 |
+
startBtn.innerHTML = '<i class="fas fa-sync-alt mr-2"></i> Analyzing...';
|
| 162 |
+
startBtn.classList.remove('bg-gray-500');
|
| 163 |
+
startBtn.classList.add('bg-green-600', 'hover:bg-green-700');
|
| 164 |
+
startBtn.onclick = null;
|
| 165 |
+
|
| 166 |
+
// Add stop button
|
| 167 |
+
const stopBtn = document.createElement('button');
|
| 168 |
+
stopBtn.className = 'ml-4 bg-red-600 hover:bg-red-700 text-white font-medium py-3 px-6 rounded-lg flex items-center transition-all duration-300 transform hover:scale-105';
|
| 169 |
+
stopBtn.innerHTML = '<i class="fas fa-stop mr-2"></i> Stop';
|
| 170 |
+
stopBtn.onclick = stopWebcam;
|
| 171 |
+
|
| 172 |
+
startBtn.parentNode.appendChild(stopBtn);
|
| 173 |
+
|
| 174 |
+
window.requestAnimationFrame(loop);
|
| 175 |
+
} catch (error) {
|
| 176 |
+
console.error('Error initializing:', error);
|
| 177 |
+
alert('Error initializing the model. Please check console for details.');
|
| 178 |
+
|
| 179 |
+
// Reset button
|
| 180 |
+
const startBtn = document.getElementById('start-btn');
|
| 181 |
+
startBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start Classification';
|
| 182 |
+
startBtn.classList.remove('bg-gray-500', 'cursor-not-allowed');
|
| 183 |
+
startBtn.classList.add('bg-indigo-600', 'hover:bg-indigo-700');
|
| 184 |
+
startBtn.disabled = false;
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
function stopWebcam() {
|
| 189 |
+
if (webcam) {
|
| 190 |
+
webcam.stop();
|
| 191 |
+
document.getElementById('webcam-container').innerHTML = `
|
| 192 |
+
<div class="text-center p-4">
|
| 193 |
+
<i class="fas fa-camera text-4xl text-gray-400 mb-2"></i>
|
| 194 |
+
<p class="text-gray-500">Camera feed will appear here</p>
|
| 195 |
+
</div>
|
| 196 |
+
`;
|
| 197 |
+
|
| 198 |
+
// Reset buttons
|
| 199 |
+
const startBtn = document.getElementById('start-btn');
|
| 200 |
+
startBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start Classification';
|
| 201 |
+
startBtn.classList.remove('bg-gray-500', 'cursor-not-allowed');
|
| 202 |
+
startBtn.classList.add('bg-indigo-600', 'hover:bg-indigo-700');
|
| 203 |
+
startBtn.onclick = init;
|
| 204 |
+
startBtn.disabled = false;
|
| 205 |
+
|
| 206 |
+
// Remove stop button
|
| 207 |
+
const stopBtn = startBtn.nextElementSibling;
|
| 208 |
+
if (stopBtn) stopBtn.remove();
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
async function loop() {
|
| 213 |
+
if (webcam) {
|
| 214 |
+
webcam.update(); // update the webcam frame
|
| 215 |
+
await predict();
|
| 216 |
+
window.requestAnimationFrame(loop);
|
| 217 |
+
}
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
// run the webcam image through the image model
|
| 221 |
+
async function predict() {
|
| 222 |
+
if (!model || !webcam) return;
|
| 223 |
+
|
| 224 |
+
// predict can take in an image, video or canvas html element
|
| 225 |
+
const predictions = await model.predict(webcam.canvas);
|
| 226 |
+
|
| 227 |
+
// Sort predictions by probability (highest first)
|
| 228 |
+
predictions.sort((a, b) => b.probability - a.probability);
|
| 229 |
+
|
| 230 |
+
// Clear previous predictions
|
| 231 |
+
labelContainer.innerHTML = '';
|
| 232 |
+
|
| 233 |
+
// Display each prediction
|
| 234 |
+
for (let i = 0; i < maxPredictions; i++) {
|
| 235 |
+
const prediction = predictions[i];
|
| 236 |
+
const probabilityPercent = Math.round(prediction.probability * 100);
|
| 237 |
+
|
| 238 |
+
// Create prediction element
|
| 239 |
+
const predictionEl = document.createElement('div');
|
| 240 |
+
predictionEl.className = 'space-y-2';
|
| 241 |
+
|
| 242 |
+
// Create label and percentage
|
| 243 |
+
const labelEl = document.createElement('div');
|
| 244 |
+
labelEl.className = 'flex justify-between text-sm font-medium text-gray-700';
|
| 245 |
+
labelEl.innerHTML = `
|
| 246 |
+
<span>${prediction.className}</span>
|
| 247 |
+
<span>${probabilityPercent}%</span>
|
| 248 |
+
`;
|
| 249 |
+
|
| 250 |
+
// Create progress bar container
|
| 251 |
+
const progressContainer = document.createElement('div');
|
| 252 |
+
progressContainer.className = 'w-full bg-gray-200 rounded-full h-2.5';
|
| 253 |
+
|
| 254 |
+
// Create progress bar
|
| 255 |
+
const progressBar = document.createElement('div');
|
| 256 |
+
progressBar.className = 'bg-gradient-to-r from-indigo-500 to-purple-500 h-3 rounded-full prediction-bar shadow-sm';
|
| 257 |
+
progressBar.style.width = `${probabilityPercent}%`;
|
| 258 |
+
|
| 259 |
+
// Add pulse animation to the highest probability prediction
|
| 260 |
+
if (i === 0 && probabilityPercent > 70) {
|
| 261 |
+
progressBar.classList.add('pulse-animation');
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
// Assemble elements
|
| 265 |
+
progressContainer.appendChild(progressBar);
|
| 266 |
+
predictionEl.appendChild(labelEl);
|
| 267 |
+
predictionEl.appendChild(progressContainer);
|
| 268 |
+
|
| 269 |
+
// Add to container
|
| 270 |
+
labelContainer.appendChild(predictionEl);
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
</script>
|
| 274 |
+
<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=Mertiego/catish-tester" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 275 |
+
</html>
|