Spaces:
Runtime error
Runtime error
Download script.js from ujan2003/Pneumonia-Detection-Web-App: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/spaces/ujan2003/Pneumonia-Detection-Web-App/resolve/main/script.js
- Command line
-
hf download hf://spaces/ujan2003/Pneumonia-Detection-Web-App/script.js
-
curl -L -o script.js https://huggingface.co/spaces/ujan2003/Pneumonia-Detection-Web-App/resolve/main/script.js
876 Bytes
| function uploadImage() { | |
| let fileInput = document.getElementById("fileInput"); | |
| let file = fileInput.files[0]; | |
| if (!file) { | |
| alert("Please select an image file."); | |
| return; | |
| } | |
| let formData = new FormData(); | |
| formData.append("file", file); | |
| fetch("http://127.0.0.1:5000/predict", { | |
| method: "POST", | |
| body: formData | |
| }) | |
| .then(response => response.json()) | |
| .then(data => { | |
| if (data.error) { | |
| document.getElementById("result").innerText = "Error: " + data.error; | |
| } else { | |
| document.getElementById("result").innerText = `Result: ${data.result} (Confidence: ${data.confidence}%)`; | |
| } | |
| }) | |
| .catch(error => { | |
| console.error("Error:", error); | |
| document.getElementById("result").innerText = "Prediction failed."; | |
| }); | |
| } | |