forked from VedikaRajashekar2005/DeepFakeDetectionAI
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
181 lines (173 loc) · 6.56 KB
/
index.html
File metadata and controls
181 lines (173 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Deepfake Detector</title>
<style>
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #2b5876, #4e4376);
text-align: center;
margin: 0;
padding: 0;
color: white;
}
.container {
width: 40%;
margin: auto;
background: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(10px);
padding: 30px;
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2);
border-radius: 12px;
margin-top: 80px;
transition: 0.3s;
}
h1 {
color: #fff;
font-size: 26px;
}
input[type="file"] {
margin: 20px 0;
border: none;
padding: 10px;
background: white;
border-radius: 6px;
cursor: pointer;
}
button {
background: linear-gradient(135deg, #ff416c, #ff4b2b);
color: white;
border: none;
padding: 12px 24px;
cursor: pointer;
font-size: 16px;
font-weight: bold;
border-radius: 6px;
transition: 0.3s;
margin-top: 15px;
}
button:hover {
background: linear-gradient(135deg, #ff4b2b, #ff416c);
transform: scale(1.05);
}
#result, #uploadMessage {
margin-top: 20px;
font-size: 18px;
font-weight: bold;
color: white;
text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
padding: 10px;
border-radius: 8px;
}
.loading-spinner {
display: none;
width: 35px;
height: 35px;
border: 4px solid rgba(255, 255, 255, 0.3);
border-top: 4px solid #fff;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 15px auto;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
img, video {
max-width: 100%;
height: auto;
margin-top: 15px;
border-radius: 8px;
display: none;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
}
.result-box {
background: rgba(255, 255, 255, 0.2);
padding: 10px;
border-radius: 8px;
display: inline-block;
margin-top: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>🔍 Deepfake Detector</h1>
<input type="file" id="fileInput" accept="image/*,video/*" onchange="displayUploadMessage()">
<p id="uploadMessage" style="display: none; color: #00ff00;">✔ File uploaded successfully!</p>
<button onclick="uploadFile()">Upload & Analyze</button>
<div class="loading-spinner" id="loadingSpinner"></div>
<p id="result"></p>
<img id="previewImage" />
<video id="previewVideo" controls></video>
</div>
<script>
function displayUploadMessage() {
document.getElementById('uploadMessage').style.display = 'block';
}
function uploadFile() {
const fileInput = document.getElementById('fileInput');
const resultText = document.getElementById('result');
const previewImage = document.getElementById('previewImage');
const previewVideo = document.getElementById('previewVideo');
const loadingSpinner = document.getElementById('loadingSpinner');
if (fileInput.files.length === 0) {
alert("📂 Please select a file to analyze.");
return;
}
const file = fileInput.files[0];
const formData = new FormData();
formData.append("file", file);
if (file.type.startsWith("image")) {
const reader = new FileReader();
reader.onload = function(e) {
previewImage.src = e.target.result;
previewImage.style.display = "block";
previewVideo.style.display = "none";
}
reader.readAsDataURL(file);
} else if (file.type.startsWith("video")) {
const reader = new FileReader();
reader.onload = function(e) {
previewVideo.src = e.target.result;
previewVideo.style.display = "block";
previewImage.style.display = "none";
}
reader.readAsDataURL(file);
}
resultText.innerText = "";
resultText.style.display = "none";
loadingSpinner.style.display = "block";
fetch("http://localhost:5000/processing_", {
method: "POST",
body: formData
})
.then(response => response.json())
.then(data => {
loadingSpinner.style.display = "none";
resultText.style.display = "block";
if (data.error) {
resultText.innerHTML = `<div class="result-box" style="color: red;">❌ Error: ${data.error}</div>`;
} else if (data.deepfake_percentage) {
resultText.innerHTML = `
<div class="result-box">
<strong>Deepfake Probability: ${data.deepfake_percentage}%</strong><br>
🎞 Frames Analyzed: ${data.total_frames_analyzed}<br>
✅ Real: ${data.real_frames} | ❌ Fake: ${data.fake_frames}
</div>
`;
} else {
resultText.innerHTML = `<div class="result-box" style="color: #28a745;">✅ ${data.message}</div>`;
}
})
.catch(error => {
loadingSpinner.style.display = "none";
resultText.style.display = "block";
resultText.innerHTML = `<div class="result-box" style="color: red;">⚠️ An error occurred. Please try again.</div>`;
});
}
</script>
</body>
</html>