hassaanik's picture
Upload 402 files
897d6d1 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Brain Tumor Prediction</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #1e1e1e;
color: #f5f5f5;
text-align: center;
}
.container {
margin: 20px auto;
max-width: 800px;
padding: 20px;
background-color: #2c2c2c;
border-radius: 10px;
}
h1 {
color: #61dafb;
}
input[type="file"] {
margin: 20px 0;
}
.result {
margin: 20px 0;
}
.result img {
max-width: 100%;
border-radius: 10px;
}
.result p {
font-size: 18px;
margin: 10px 0;
}
</style>
</head>
<body>
<div class="container">
<h1>Brain Tumor Detection</h1>
<form id="upload-form">
<input type="file" id="file-input" accept="image/*" />
<button type="submit">Upload and Predict</button>
</form>
<div class="result" id="result">
<img id="input-image" src="" alt="Input Image" />
<img id="mask-image" src="" alt="Predicted Mask Image" />
<p id="class-label"></p>
<p id="probability"></p>
</div>
</div>
<script>
document.getElementById('upload-form').onsubmit = async (e) => {
e.preventDefault();
const fileInput = document.getElementById('file-input');
const file = fileInput.files[0];
const formData = new FormData();
formData.append('file', file);
const response = await fetch('/predict', {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.error) {
alert('Error: ' + data.error);
return;
}
document.getElementById('input-image').src = 'data:image/png;base64,' + data.input_image;
document.getElementById('mask-image').src = 'data:image/png;base64,' + data.mask_image;
document.getElementById('class-label').innerText = 'Class Prediction: ' + data.class_label;
document.getElementById('probability').innerText = 'Confidence: ' + (data.probability * 100).toFixed(2) + '%';
};
</script>
</body>
</html>