File size: 6,124 Bytes
5c72df4 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Image Classifier</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<div id="headerContainer" class="header-container">
<h1>Poultry AI</h1>
</div>
<div id="mainContainer" style="display: flex;">
<div id="inputContainer" style="flex-grow: 1;">
<input type="file" id="uploadInput">
<button id="uploadButton">Upload</button>
<div id="predictionResult"></div>
<div id="diseaseInfo" style="display: none;">
<h2>General Precaution</h2>
<div id="diseaseDescription"></div>
<div id="prevention"></div>
<div id="suggestions"></div>
</div>
</div>
<div id="uploadedImageContainer" style="flex-grow: 1; margin-left: 20px;">
<img id="uploadedImage" src="#" alt="Uploaded Image" style="max-width: 100%; max-height: 300px; display: none;">
</div>
</div>
<script>
const allowedExtensions = ['png', 'jpg', 'jpeg', 'gif'];
document.getElementById('uploadInput').addEventListener('change', function() {
const fileInput = document.getElementById('uploadInput');
const file = fileInput.files[0];
if (!file) {
alert('Please select a file.');
return;
}
const fileExtension = file.name.split('.').pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension)) {
alert('This file is not supported');
fileInput.value = ''; // Reset the file input
return;
}
// Display uploaded image
const uploadedImage = document.getElementById('uploadedImage');
uploadedImage.src = URL.createObjectURL(file);
uploadedImage.style.display = 'block';
});
document.getElementById('uploadButton').addEventListener('click', async function() {
const fileInput = document.getElementById('uploadInput');
const file = fileInput.files[0];
if (!file) {
alert('Please select a file.');
return;
}
const fileExtension = file.name.split('.').pop().toLowerCase();
if (!allowedExtensions.includes(fileExtension)) {
alert('This file is not supported');
fileInput.value = ''; // Reset the file input
return;
}
const formData = new FormData();
formData.append('file', file);
try {
const response = await fetch('/predict', {
method: 'POST',
body: formData
});
const data = await response.json();
document.getElementById('predictionResult').innerText = data.prediction;
// Display additional information based on prediction
const diseaseInfo = document.getElementById('diseaseInfo');
const diseaseDescription = document.getElementById('diseaseDescription');
const prevention = document.getElementById('prevention');
const suggestions = document.getElementById('suggestions');
// Reset previous content
diseaseDescription.innerHTML = '';
prevention.innerHTML = '';
suggestions.innerHTML = '';
switch (data.prediction.toLowerCase()) {
case 'salmo':
diseaseDescription.innerHTML = 'Salmonellosis is caused by Salmonella bacteria and can lead to digestive tract infections in poultry.';
prevention.innerHTML = 'Implement strict biosecurity measures on the farm to prevent contamination. Provide clean water and feed.';
suggestions.innerHTML = 'Consult a veterinarian for guidance on vaccination programs and proper antibiotic use if necessary.';
diseaseInfo.style.display = 'block';
break;
case 'healthy':
diseaseDescription.innerHTML = 'No disease detected. The image indicates a healthy condition in the poultry.';
diseaseInfo.style.display = 'none';
break;
case 'ncd':
diseaseDescription.innerHTML = 'Newcastle disease (NCD) is a viral disease affecting poultry respiratory, nervous, and digestive systems.';
prevention.innerHTML = 'Implement strict biosecurity measures on the farm. Vaccinate birds against Newcastle disease.';
suggestions.innerHTML = 'Consult a veterinarian ';
diseaseInfo.style.display = 'block';
break;
case 'cocci':
diseaseDescription.innerHTML = 'Coccidiosis is caused by protozoa of the genus Eimeria, affecting the intestinal tract of poultry.';
prevention.innerHTML = 'Practice proper sanitation and hygiene measures in the poultry house. ';
suggestions.innerHTML = 'Consult a veterinarian for guidance on coccidiosis prevention and control strategies tailored to your flock.';
diseaseInfo.style.display = 'block';
break;
default:
// If prediction does not match any specific case, hide the additional info
diseaseInfo.style.display = 'none';
break;
}
} catch (error) {
console.error('Error:', error);
}
});
</script>
</body>
</html>
|