Spaces:
Runtime error
Runtime error
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Plant Disease Detector</title> | |
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> | |
| <style> | |
| body { | |
| background-color: #f8f9fa; | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| } | |
| .hero-section { | |
| background-color: #28a745; | |
| color: white; | |
| padding: 3rem 0; | |
| margin-bottom: 2rem; | |
| } | |
| .upload-container { | |
| background-color: white; | |
| border-radius: 10px; | |
| padding: 2rem; | |
| box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); | |
| } | |
| .instructions { | |
| background-color: #e9f7ef; | |
| border-left: 4px solid #28a745; | |
| padding: 1rem; | |
| margin-bottom: 1.5rem; | |
| } | |
| .preview-container { | |
| max-width: 300px; | |
| max-height: 300px; | |
| overflow: hidden; | |
| margin: 0 auto; | |
| border: 2px dashed #dee2e6; | |
| border-radius: 5px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| } | |
| #imagePreview { | |
| max-width: 100%; | |
| max-height: 100%; | |
| display: none; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="hero-section"> | |
| <div class="container text-center"> | |
| <h1 class="display-4">Plant Disease & Pest Detector</h1> | |
| <p class="lead">Upload an image of your plant to detect diseases and pests</p> | |
| </div> | |
| </div> | |
| <div class="container mb-5"> | |
| {% with messages = get_flashed_messages() %} | |
| {% if messages %} | |
| {% for message in messages %} | |
| <div class="alert alert-warning alert-dismissible fade show" role="alert"> | |
| {{ message }} | |
| <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | |
| </div> | |
| {% endfor %} | |
| {% endif %} | |
| {% endwith %} | |
| <div class="row justify-content-center"> | |
| <div class="col-md-8"> | |
| <div class="upload-container"> | |
| <div class="instructions"> | |
| <h5>How to use:</h5> | |
| <ol> | |
| <li>Select an image of your plant (preferably showing affected areas)</li> | |
| <li>Enter the name of the plant (e.g., Tomato, Rice, Potato)</li> | |
| <li>Click "Analyze Plant" to detect diseases or pests</li> | |
| </ol> | |
| </div> | |
| <form action="/analyze" method="post" enctype="multipart/form-data"> | |
| <div class="mb-4"> | |
| <div class="preview-container mb-3"> | |
| <img id="imagePreview" src="#" alt="Image Preview"> | |
| <span id="previewPlaceholder">Image preview will appear here</span> | |
| </div> | |
| <label for="plant_image" class="form-label">Upload Plant Image</label> | |
| <input class="form-control" type="file" id="plant_image" name="plant_image" accept="image/*" required onchange="previewImage(event)"> | |
| </div> | |
| <div class="mb-4"> | |
| <label for="plant_name" class="form-label">Plant Name</label> | |
| <input type="text" class="form-control" id="plant_name" name="plant_name" placeholder="e.g., Tomato, Rice, Potato" required> | |
| </div> | |
| <div class="mb-4"> | |
| <label for="language" class="form-label">Response Language</label> | |
| <select class="form-control" id="language" name="language" required> | |
| <option value="English">English</option> | |
| <option value="Hindi">Hindi</option> | |
| <option value="Bengali">Bengali</option> | |
| <option value="Telugu">Telugu</option> | |
| <option value="Marathi">Marathi</option> | |
| <option value="Tamil">Tamil</option> | |
| <option value="Gujarati">Gujarati</option> | |
| <option value="Urdu">Urdu</option> | |
| <option value="Kannada">Kannada</option> | |
| <option value="Odia">Odia</option> | |
| <option value="Malayalam">Malayalam</option> | |
| </select> | |
| </div> | |
| <div class="d-grid"> | |
| <button type="submit" class="btn btn-success btn-lg">Analyze Plant</button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Loading Overlay --> | |
| <div id="loadingOverlay" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(255, 255, 255, 0.8); z-index: 1050; align-items: center; justify-content: center;"> | |
| <div class="text-center"> | |
| <div class="spinner-border text-success" role="status" style="width: 4rem; height: 4rem;"> | |
| <span class="visually-hidden">Loading...</span> | |
| </div> | |
| <div class="mt-3"> | |
| <h4>Processing, please wait...</h4> | |
| </div> | |
| </div> | |
| </div> | |
| <footer class="bg-dark text-white text-center py-3"> | |
| <div class="container"> | |
| <p class="mb-0">Plant Disease Detector © 2025 | Powered by Gemini AI</p> | |
| </div> | |
| </footer> | |
| <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> | |
| <script> | |
| function previewImage(event) { | |
| var reader = new FileReader(); | |
| reader.onload = function() { | |
| var output = document.getElementById('imagePreview'); | |
| output.src = reader.result; | |
| output.style.display = 'block'; | |
| document.getElementById('previewPlaceholder').style.display = 'none'; | |
| }; | |
| reader.readAsDataURL(event.target.files[0]); | |
| } | |
| // Show loading overlay on form submit | |
| document.addEventListener("DOMContentLoaded", function() { | |
| const form = document.querySelector("form"); | |
| form.addEventListener("submit", function() { | |
| document.getElementById("loadingOverlay").style.display = "flex"; | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |