VIT-css / index.html
zaman855's picture
Update index.html
f5864cf verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Skin Disease Detection using Vision Transformer</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
background-color: #f0f2f5;
color: #333;
}
h1 {
margin-top: 20px;
font-size: 2em;
color: #4a90e2;
}
.upload-container {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 20px;
text-align: center;
margin: 20px 0;
width: 80%;
max-width: 500px;
}
input[type="file"] {
margin: 20px 0;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
width: calc(100% - 22px);
}
button {
padding: 10px 20px;
font-size: 16px;
background-color: #4a90e2;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #357ab8;
}
.result {
margin-top: 20px;
font-size: 1.1em;
font-weight: bold;
color: #333;
}
.image-preview {
margin-top: 20px;
max-width: 100%;
height: auto;
border: 1px solid #ccc;
border-radius: 5px;
}
.iframe-container {
width: 90%;
max-width: 850px;
height: 450px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
border-radius: 10px;
overflow: hidden;
margin-bottom: 20px;
}
iframe {
width: 100%;
height: 100%;
border: none;
}
</style>
</head>
<body>
<h1>Skin Disease Detection using Vision Transformer</h1>
<!-- Upload and Prediction Section -->
<div class="upload-container">
<input type="file" id="file-input" accept="image/*" required />
<button onclick="uploadImage()" id="upload-button">Upload and Predict</button>
<div class="result" id="result"></div>
<img id="image-preview" class="image-preview" style="display: none;" />
</div>
<script>
document.getElementById('file-input').addEventListener('change', previewImage);
function previewImage() {
const fileInput = document.getElementById('file-input');
const imagePreview = document.getElementById('image-preview');
const file = fileInput.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
imagePreview.src = e.target.result;
imagePreview.style.display = 'block';
};
reader.readAsDataURL(file);
}
}
async function uploadImage() {
const fileInput = document.getElementById('file-input');
const resultDiv = document.getElementById('result');
const uploadButton = document.getElementById('upload-button');
const imagePreview = document.getElementById('image-preview');
if (!fileInput.files.length) {
alert("Please select a file.");
return;
}
resultDiv.textContent = '';
uploadButton.disabled = true;
const formData = new FormData();
formData.append('file', fileInput.files[0]);
resultDiv.textContent = 'Predicting...';
try {
const response = await fetch('https://zaman855-vit-css.hf.space/predict/', {
method: 'POST',
body: formData
});
if (response.ok) {
const data = await response.json();
resultDiv.textContent = `Predicted Class: ${data.predicted_class}, Confidence: ${data.confidence.toFixed(2)}`;
} else {
resultDiv.textContent = 'Error: Prediction failed.';
}
} catch (error) {
console.error('Error:', error);
resultDiv.textContent = 'Error: Unable to connect to the server.';
} finally {
uploadButton.disabled = false;
}
}
</script>
</body>
</html>