-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
29 lines (29 loc) · 1.01 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Detect your beer</title>
</head>
<body>
<input id="photo" type="file">
<div id="results"></div>
<script>
async function run(reader) {
const response = await fetch('https://adam1105-ug-practical-deeplearning-fastai-2023.hf.space/run/predict/', {
method: "POST", body: JSON.stringify({ "data": [reader.result] }),
headers: { "Content-Type": "application/json" }
});
const json = await response.json();
const json_str = JSON.stringify(json);
const label = json["data"][0]["label"]
results.innerHTML = `<br/><img src="${reader.result}" width="300"> <p>${label}</p>`
}
function read() {
const reader = new FileReader();
reader.addEventListener('load', () => run(reader))
reader.readAsDataURL(photo.files[0]);
}
photo.addEventListener('input', read);
</script>
</body>
</html>