| <!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 = '';
|
| return;
|
| }
|
|
|
|
|
| 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 = '';
|
| 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;
|
|
|
|
|
| const diseaseInfo = document.getElementById('diseaseInfo');
|
| const diseaseDescription = document.getElementById('diseaseDescription');
|
| const prevention = document.getElementById('prevention');
|
| const suggestions = document.getElementById('suggestions');
|
|
|
|
|
| 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:
|
|
|
| diseaseInfo.style.display = 'none';
|
| break;
|
| }
|
| } catch (error) {
|
| console.error('Error:', error);
|
| }
|
| });
|
| </script>
|
| </body>
|
| </html>
|
|
|