Spaces:
Running
Running
Update static/index.html
Browse files- 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
|
7 |
</head>
|
8 |
<body>
|
9 |
-
<h1>Sketch
|
10 |
-
<form id="
|
11 |
-
<input type="file"
|
12 |
<button type="submit">Submit</button>
|
13 |
</form>
|
14 |
-
<
|
|
|
15 |
|
16 |
<script>
|
17 |
-
document.getElementById(
|
18 |
event.preventDefault();
|
19 |
const formData = new FormData();
|
20 |
-
formData.append(
|
21 |
-
|
22 |
-
|
23 |
-
method: 'POST',
|
24 |
body: formData
|
25 |
});
|
26 |
-
|
27 |
-
const
|
28 |
-
|
29 |
-
document.getElementById(
|
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>
|