MySafeCode commited on
Commit
066f75f
·
verified ·
1 Parent(s): e0a1fd2

Upload static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +158 -0
static/index.html ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Depth Video BG Remover</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ </head>
9
+ <body class="bg-gradient-to-r from-purple-400 to-blue-500 min-h-screen p-4">
10
+ <div class="max-w-4xl mx-auto bg-white rounded-2xl shadow-xl p-6">
11
+ <h1 class="text-3xl font-bold text-center text-gray-800 mb-2">
12
+ 🎥 Depth Video Background Remover
13
+ </h1>
14
+ <p class="text-center text-gray-600 mb-6">
15
+ Remove video backgrounds using AI depth estimation
16
+ </p>
17
+
18
+ <!-- Upload Area -->
19
+ <div id="uploadArea" class="border-4 border-dashed border-gray-300 rounded-lg p-8 text-center cursor-pointer hover:border-purple-500 transition">
20
+ <input type="file" id="fileInput" accept="video/*" class="hidden">
21
+ <div class="text-5xl mb-2">📁</div>
22
+ <p class="text-lg font-medium">Click or drag to upload video</p>
23
+ <p class="text-sm text-gray-500">MP4, MOV, AVI (max 50MB)</p>
24
+ </div>
25
+
26
+ <!-- Controls -->
27
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4 my-6">
28
+ <div class="bg-gray-100 p-4 rounded-lg">
29
+ <label class="block font-medium mb-2">
30
+ Depth Threshold: <span id="thresholdVal">0.3</span>
31
+ </label>
32
+ <input type="range" id="threshold" min="0.1" max="0.9" step="0.05" value="0.3" class="w-full">
33
+ <p class="text-xs text-gray-500 mt-1">Lower = more background removed</p>
34
+ </div>
35
+
36
+ <div class="bg-gray-100 p-4 rounded-lg">
37
+ <label class="block font-medium mb-2">Background Color</label>
38
+ <input type="color" id="bgColor" value="#00FF00" class="w-full h-10">
39
+ </div>
40
+ </div>
41
+
42
+ <!-- Process Button -->
43
+ <button id="processBtn" disabled class="w-full bg-gradient-to-r from-purple-600 to-blue-600 text-white font-bold py-3 px-4 rounded-lg text-lg disabled:opacity-50 disabled:cursor-not-allowed mb-6">
44
+ ✨ Process Video
45
+ </button>
46
+
47
+ <!-- Loading -->
48
+ <div id="loading" class="text-center hidden">
49
+ <div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-purple-700 mb-2"></div>
50
+ <p>Processing video... This may take a minute.</p>
51
+ </div>
52
+
53
+ <!-- Preview -->
54
+ <div id="preview" class="hidden grid grid-cols-1 md:grid-cols-2 gap-4">
55
+ <div>
56
+ <h3 class="font-medium mb-2">Original</h3>
57
+ <video id="originalVideo" controls class="w-full rounded-lg bg-black"></video>
58
+ </div>
59
+ <div>
60
+ <h3 class="font-medium mb-2">Result</h3>
61
+ <video id="resultVideo" controls class="w-full rounded-lg bg-black"></video>
62
+ <div id="downloadArea" class="mt-2 text-center"></div>
63
+ </div>
64
+ </div>
65
+ </div>
66
+
67
+ <script>
68
+ const fileInput = document.getElementById('fileInput');
69
+ const uploadArea = document.getElementById('uploadArea');
70
+ const processBtn = document.getElementById('processBtn');
71
+ const loading = document.getElementById('loading');
72
+ const preview = document.getElementById('preview');
73
+ const originalVideo = document.getElementById('originalVideo');
74
+ const resultVideo = document.getElementById('resultVideo');
75
+ const threshold = document.getElementById('threshold');
76
+ const thresholdVal = document.getElementById('thresholdVal');
77
+ const bgColor = document.getElementById('bgColor');
78
+ const downloadArea = document.getElementById('downloadArea');
79
+
80
+ let currentFile = null;
81
+
82
+ // Update threshold display
83
+ threshold.addEventListener('input', () => {
84
+ thresholdVal.textContent = threshold.value;
85
+ });
86
+
87
+ // Upload handlers
88
+ uploadArea.addEventListener('click', () => fileInput.click());
89
+
90
+ uploadArea.addEventListener('dragover', (e) => {
91
+ e.preventDefault();
92
+ uploadArea.classList.add('border-purple-500');
93
+ });
94
+
95
+ uploadArea.addEventListener('dragleave', () => {
96
+ uploadArea.classList.remove('border-purple-500');
97
+ });
98
+
99
+ uploadArea.addEventListener('drop', (e) => {
100
+ e.preventDefault();
101
+ uploadArea.classList.remove('border-purple-500');
102
+ const file = e.dataTransfer.files[0];
103
+ if (file && file.type.startsWith('video/')) {
104
+ handleFile(file);
105
+ }
106
+ });
107
+
108
+ fileInput.addEventListener('change', (e) => {
109
+ if (e.target.files[0]) handleFile(e.target.files[0]);
110
+ });
111
+
112
+ function handleFile(file) {
113
+ currentFile = file;
114
+ processBtn.disabled = false;
115
+ originalVideo.src = URL.createObjectURL(file);
116
+ preview.classList.remove('hidden');
117
+ }
118
+
119
+ // Process video
120
+ processBtn.addEventListener('click', async () => {
121
+ if (!currentFile) return;
122
+
123
+ loading.classList.remove('hidden');
124
+ processBtn.disabled = true;
125
+
126
+ const formData = new FormData();
127
+ formData.append('file', currentFile);
128
+ formData.append('threshold', threshold.value);
129
+ formData.append('bg_color', bgColor.value);
130
+
131
+ try {
132
+ const response = await fetch('/process', {
133
+ method: 'POST',
134
+ body: formData
135
+ });
136
+
137
+ if (!response.ok) throw new Error('Processing failed');
138
+
139
+ const blob = await response.blob();
140
+ const url = URL.createObjectURL(blob);
141
+ resultVideo.src = url;
142
+
143
+ downloadArea.innerHTML = `
144
+ <a href="${url}" download="processed.mp4"
145
+ class="inline-block bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700">
146
+ ⬇️ Download Video
147
+ </a>
148
+ `;
149
+ } catch (error) {
150
+ alert('Error: ' + error.message);
151
+ } finally {
152
+ loading.classList.add('hidden');
153
+ processBtn.disabled = false;
154
+ }
155
+ });
156
+ </script>
157
+ </body>
158
+ </html>