Ashrafb commited on
Commit
d3a8a22
·
verified ·
1 Parent(s): 7247146

Update static/index.html

Browse files
Files changed (1) hide show
  1. 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>Image Processing</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
  <body>
9
- <h1>Image Processing</h1>
10
- <form id="imageForm">
11
- <label for="sourceImage">Source Image (Base64 Encoded):</label><br>
12
- <textarea id="sourceImage" name="source_image_base64" rows="4" cols="50"></textarea><br>
13
- <label for="sourceFacePosition">Source Face Position:</label><br>
14
- <input type="number" id="sourceFacePosition" name="source_face_position"><br>
15
- <label for="destinationImage">Destination Image (Base64 Encoded):</label><br>
16
- <textarea id="destinationImage" name="destination_image_base64" rows="4" cols="50"></textarea><br>
17
- <label for="destinationFacePosition">Destination Face Position:</label><br>
18
- <input type="number" id="destinationFacePosition" name="destination_face_position"><br>
19
- <button type="button" onclick="submitForm()">Submit</button>
20
- </form>
 
21
 
22
  <script>
23
- function submitForm() {
24
- var form = document.getElementById("imageForm");
25
- var formData = new FormData(form);
26
- var jsonData = {};
27
- formData.forEach(function(value, key){
28
- jsonData[key] = value;
29
- });
30
- fetch('/predict', {
31
- method: 'get',
32
- headers: {
33
- 'Content-Type': 'application/json'
34
- },
35
- body: JSON.stringify(jsonData)
36
- }).then(response => {
37
- if (response.ok) {
38
- return response.json();
39
- } else {
40
- throw new Error('Failed to submit form');
41
- }
42
- }).then(data => {
43
- console.log(data);
44
- // Handle response data as needed
45
- }).catch(error => {
46
- console.error(error);
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>