Update static/index.html
Browse files- static/index.html +75 -40
static/index.html
CHANGED
|
@@ -3,50 +3,85 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
</head>
|
| 8 |
<body>
|
| 9 |
-
<
|
| 10 |
-
|
| 11 |
-
<
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
<
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
<script>
|
| 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 |
-
// Handle errors
|
| 48 |
-
});
|
| 49 |
-
}
|
| 50 |
</script>
|
| 51 |
</body>
|
| 52 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Face Swap App</title>
|
| 7 |
+
<style>
|
| 8 |
+
body {
|
| 9 |
+
font-family: Arial, sans-serif;
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
display: flex;
|
| 13 |
+
justify-content: center;
|
| 14 |
+
align-items: center;
|
| 15 |
+
height: 100vh;
|
| 16 |
+
background-color: #f4f4f4;
|
| 17 |
+
}
|
| 18 |
+
.container {
|
| 19 |
+
text-align: center;
|
| 20 |
+
}
|
| 21 |
+
h1 {
|
| 22 |
+
margin-bottom: 20px;
|
| 23 |
+
}
|
| 24 |
+
input[type="file"] {
|
| 25 |
+
display: none;
|
| 26 |
+
}
|
| 27 |
+
label {
|
| 28 |
+
background-color: #007bff;
|
| 29 |
+
color: #fff;
|
| 30 |
+
padding: 10px 20px;
|
| 31 |
+
cursor: pointer;
|
| 32 |
+
border-radius: 5px;
|
| 33 |
+
font-weight: bold;
|
| 34 |
+
}
|
| 35 |
+
#preview {
|
| 36 |
+
margin-top: 20px;
|
| 37 |
+
}
|
| 38 |
+
img {
|
| 39 |
+
max-width: 100%;
|
| 40 |
+
max-height: 300px;
|
| 41 |
+
margin-top: 10px;
|
| 42 |
+
}
|
| 43 |
+
</style>
|
| 44 |
</head>
|
| 45 |
<body>
|
| 46 |
+
<div class="container">
|
| 47 |
+
<h1>Face Swap App</h1>
|
| 48 |
+
<form id="uploadForm" enctype="multipart/form-data">
|
| 49 |
+
<label for="sourceImage">Select Source Image:</label>
|
| 50 |
+
<input type="file" id="sourceImage" name="sourceImage" accept="image/*" required>
|
| 51 |
+
<br>
|
| 52 |
+
<label for="destinationImage">Select Destination Image:</label>
|
| 53 |
+
<input type="file" id="destinationImage" name="destinationImage" accept="image/*" required>
|
| 54 |
+
<br>
|
| 55 |
+
<button type="submit">Swap Faces</button>
|
| 56 |
+
</form>
|
| 57 |
+
<div id="preview"></div>
|
| 58 |
+
</div>
|
| 59 |
|
| 60 |
<script>
|
| 61 |
+
const form = document.getElementById('uploadForm');
|
| 62 |
+
const preview = document.getElementById('preview');
|
| 63 |
+
|
| 64 |
+
form.addEventListener('submit', async (e) => {
|
| 65 |
+
e.preventDefault();
|
| 66 |
+
const formData = new FormData(form);
|
| 67 |
+
|
| 68 |
+
try {
|
| 69 |
+
const response = await fetch('/predict', {
|
| 70 |
+
method: 'POST',
|
| 71 |
+
body: formData
|
| 72 |
+
});
|
| 73 |
+
const result = await response.json();
|
| 74 |
+
console.log(result);
|
| 75 |
+
|
| 76 |
+
preview.innerHTML = `
|
| 77 |
+
<h2>Result:</h2>
|
| 78 |
+
<p>Source Face Position: ${result.source_face_position}</p>
|
| 79 |
+
<p>Destination Face Position: ${result.destination_face_position}</p>
|
| 80 |
+
`;
|
| 81 |
+
} catch (error) {
|
| 82 |
+
console.error('Error:', error);
|
| 83 |
+
}
|
| 84 |
+
});
|
|
|
|
|
|
|
|
|
|
| 85 |
</script>
|
| 86 |
</body>
|
| 87 |
</html>
|