-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (65 loc) · 2.6 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>DermAI</title>
<link rel="stylesheet" href="styles.css">
<script src="index.js"></script>
</head>
<body onload="">
<header>
<div class="logo">
<h1 class="fancy-text">DermAI</h1>
<img src="logo.png" alt="DermAI Logo" width="50" height="50" class="logo">
</div>
<div class="tab-container">
<ul class="tabs">
<li><a href="index.html">Upload Image</a></li>
<li><a href="findDermatologist/findDermatologist.html">Find a Dermatologist</a></li>
<li><a href="diseaseTypes/diseaseTypes.html">Supported Skin Diseases</a></li>
</ul>
</div>
</header>
<div class="top-container">
<div>
<input type="file" style="display:none" id="image-input">
<button id="upload-image" onclick="upload()" type="uploadFile">Upload Image</button>
<button id="predictButton" type="button">Predict conditions</button>
</div>
<br>
</div>
<!-- AI section to pull data from dataset.json for name, short paragraph, image, and link -->
<div class="container">
<div id="shortDescription">
<h1>What kind of death inducing disease do you have today? :)</h1>
<h2 id="name"></h2>
<p id="shortDescription"></p>
<img id="image" src="" />
<a id="link" href="">Link</a>
</div>
</div>
<script>
const predictButton = document.getElementById("predictButton");
const fileInput = document.getElementById("image-input");
const result = document.getElementById("shortDescription");
predictButton.addEventListener("click", () => {
const file = fileInput.files[0];
const formData = new FormData();
formData.append("image", file);
fetch("/predict", {
method: "POST",
body: formData,
})
.then((response) => response.json())
.then((data) => {
console.log(data);
result.innerHTML = `Most predicted disease type: ${data.category}, Probability: ${data.probability}, Specific disease: ${data.disease}, Probability: ${data.disease_prob},
Second-most predicted disease type: ${data.category2}, Probability: ${data.c2_prob}, Specific disease: ${data.disease2}, Probability: ${data.d2_prob},`;
})
.catch((error) => {
console.error(error);
result.innerHTML = "An error occurred.";
});
});
</script>
</body>
</html>