Ashrafb commited on
Commit
4d1d14d
·
verified ·
1 Parent(s): 2c151eb

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +14 -14
static/index.html CHANGED
@@ -3,30 +3,30 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Sketch Prediction</title>
7
  </head>
8
  <body>
9
- <h1>Sketch Prediction</h1>
10
- <form id="uploadForm" enctype="multipart/form-data">
11
- <input type="file" id="fileInput" name="file" accept="image/*">
12
  <button type="submit">Submit</button>
13
  </form>
14
- <div id="result"></div>
 
15
 
16
  <script>
17
- document.getElementById('uploadForm').addEventListener('submit', async function(event) {
18
  event.preventDefault();
19
  const formData = new FormData();
20
- formData.append('file', document.getElementById('fileInput').files[0]);
21
-
22
- const response = await fetch('/predict/', {
23
- method: 'POST',
24
  body: formData
25
  });
26
-
27
- const data = await response.blob();
28
- const url = URL.createObjectURL(data);
29
- document.getElementById('result').innerHTML = `<img src="${url}" alt="Prediction Result">`;
30
  });
31
  </script>
32
  </body>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Image to Sketch</title>
7
  </head>
8
  <body>
9
+ <h1>Upload Image to Get Sketch</h1>
10
+ <form id="upload-form" action="/predict" method="post" enctype="multipart/form-data">
11
+ <input type="file" name="file" id="file-input">
12
  <button type="submit">Submit</button>
13
  </form>
14
+ <h2>Sketch Result:</h2>
15
+ <div id="resultcontainer"></div>
16
 
17
  <script>
18
+ document.getElementById("upload-form").addEventListener("submit", async function(event) {
19
  event.preventDefault();
20
  const formData = new FormData();
21
+ formData.append("file", document.getElementById("file-input").files[0]);
22
+ const response = await fetch("/predict", {
23
+ method: "POST",
 
24
  body: formData
25
  });
26
+ const data = await response.json();
27
+ const sketchImage = data.sketch_image;
28
+ // Update the result container with the sketch image
29
+ document.getElementById("resultcontainer").innerHTML = `<img src="${sketchImage}" alt="Sketch Image">`;
30
  });
31
  </script>
32
  </body>