Spaces:
Sleeping
Sleeping
| function uploadImage() { | |
| const fileInput = document.getElementById("fileInput"); | |
| const file = fileInput.files[0]; | |
| if (!file) return; | |
| document.getElementById("loading").classList.remove("hidden"); | |
| document.getElementById("result").innerText = ""; | |
| const formData = new FormData(); | |
| formData.append("file", file); | |
| fetch("/predict", { | |
| method: "POST", | |
| body: formData, | |
| }) | |
| .then((res) => res.json()) | |
| .then((data) => { | |
| document.getElementById("loading").classList.add("hidden"); | |
| document.getElementById("result").innerText = "Prediction: " + data.result; | |
| }) | |
| .catch((err) => { | |
| document.getElementById("loading").classList.add("hidden"); | |
| document.getElementById("result").innerText = "Error during prediction."; | |
| }); | |
| } | |