| <!doctype html> |
| <html> |
| <head> |
| <title>Skin Lesion Screening</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <style> |
| body { |
| font-family: Arial, sans-serif; |
| margin: 40px; |
| background-color: #f9f9f9; |
| } |
| .container { |
| max-width: 500px; |
| margin: auto; |
| background: #fff; |
| padding: 20px; |
| border-radius: 8px; |
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); |
| text-align: center; |
| } |
| input, select, button { |
| width: 100%; |
| padding: 10px; |
| margin: 10px 0; |
| font-size: 1em; |
| } |
| button { |
| background-color: #007BFF; |
| border: none; |
| color: white; |
| cursor: pointer; |
| border-radius: 4px; |
| } |
| button:hover { |
| background-color: #0056b3; |
| } |
| .result { |
| margin-top: 20px; |
| font-size: 1.2em; |
| color: #333; |
| white-space: pre-line; |
| } |
| </style> |
| </head> |
| <body> |
| <div class="container"> |
| <h1>Skin Lesion Screening</h1> |
| <form id="upload-form"> |
| |
| <label for="file">Upload Image:</label> |
| <input type="file" id="file" accept="image/*" capture="camera" required> |
| |
| |
| <label for="age">Age:</label> |
| <input type="number" id="age" placeholder="Enter your age" required> |
| |
| |
| <label for="gender">Gender:</label> |
| <select id="gender" required> |
| <option value="" disabled selected>Select your gender</option> |
| <option value="0">Male</option> |
| <option value="1">Female</option> |
| <option value="2">Other</option> |
| </select> |
| |
| |
| <label for="cancerHistory">History of Skin Cancer:</label> |
| <select id="cancerHistory" required> |
| <option value="" disabled selected>Do you have a history of skin cancer?</option> |
| <option value="0">No</option> |
| <option value="1">Yes</option> |
| </select> |
| |
| <button type="submit">Analyze</button> |
| </form> |
| <div id="result" class="result"></div> |
| </div> |
| <script> |
| document.getElementById('upload-form').addEventListener('submit', async function(e) { |
| e.preventDefault(); |
| |
| |
| const fileInput = document.getElementById('file'); |
| const ageInput = document.getElementById('age'); |
| const genderInput = document.getElementById('gender'); |
| const cancerHistoryInput = document.getElementById('cancerHistory'); |
| |
| if (!fileInput.files.length) { |
| alert("Please select an image file."); |
| return; |
| } |
| |
| |
| const formData = new FormData(); |
| formData.append('file', fileInput.files[0]); |
| formData.append('age', ageInput.value); |
| formData.append('gender', genderInput.value); |
| formData.append('cancer_history', cancerHistoryInput.value); |
| |
| |
| const functionUrl = 'https://us-central1-skincancerscreening.cloudfunctions.net/predict'; |
| |
| |
| try { |
| const response = await fetch(functionUrl, { |
| method: 'POST', |
| body: formData |
| }); |
| |
| if (!response.ok) { |
| throw new Error("Network response was not ok"); |
| } |
| |
| const data = await response.json(); |
| document.getElementById('result').innerText = |
| 'Predicted Class: ' + data.predicted_class + '\nConfidence: ' + (data.confidence * 100).toFixed(2) + '%'; |
| } catch (error) { |
| document.getElementById('result').innerText = 'Error: ' + error; |
| } |
| }); |
| </script> |
| </body> |
| </html> |
|
|