Download index.html from ferides/mushroom-classifier-mlops: direct link, hf CLI and curl.
- Browser
- Download file 15.5 kB
-
https://huggingface.co/spaces/ferides/mushroom-classifier-mlops/resolve/main/index.html
- Command line
-
hf download hf://spaces/ferides/mushroom-classifier-mlops/index.html
-
curl -L -o index.html https://huggingface.co/spaces/ferides/mushroom-classifier-mlops/resolve/main/index.html
15.5 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <meta name="description" content="AI-powered mushroom image classification"> | |
| <title>Mushroom Safety Classifier</title> | |
| <style> | |
| :root { | |
| --forest: #18392b; | |
| --forest-light: #285c43; | |
| --cream: #fffaf0; | |
| --paper: #f5ead5; | |
| --rust: #bd5b31; | |
| --gold: #d99b3d; | |
| --brown: #52392b; | |
| --muted: #6d766f; | |
| --white: #ffffff; | |
| --danger: #a9382d; | |
| --safe: #24754a; | |
| --shadow: 0 22px 60px rgba(42, 47, 35, 0.16); | |
| } | |
| * { | |
| box-sizing: border-box; | |
| } | |
| body { | |
| margin: 0; | |
| min-height: 100vh; | |
| color: var(--brown); | |
| font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; | |
| background: | |
| radial-gradient(circle at 10% 10%, rgba(217, 155, 61, 0.22), transparent 28%), | |
| radial-gradient(circle at 90% 80%, rgba(40, 92, 67, 0.18), transparent 32%), | |
| linear-gradient(135deg, #f8edd8 0%, #fffaf0 48%, #e7ead8 100%); | |
| } | |
| .page { | |
| width: min(1180px, calc(100% - 32px)); | |
| margin: auto; | |
| padding: 28px 0 38px; | |
| } | |
| .topbar { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 28px; | |
| } | |
| .brand { | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| color: var(--forest); | |
| font-weight: 800; | |
| } | |
| .brand-icon { | |
| display: grid; | |
| place-items: center; | |
| width: 46px; | |
| height: 46px; | |
| border-radius: 15px; | |
| background: var(--forest); | |
| color: white; | |
| font-size: 25px; | |
| box-shadow: 0 12px 25px rgba(24, 57, 43, 0.24); | |
| } | |
| .status { | |
| display: flex; | |
| align-items: center; | |
| gap: 8px; | |
| padding: 9px 14px; | |
| border: 1px solid rgba(36, 117, 74, 0.18); | |
| border-radius: 999px; | |
| background: rgba(255, 255, 255, 0.68); | |
| color: var(--safe); | |
| font-size: 13px; | |
| font-weight: 700; | |
| } | |
| .status-dot { | |
| width: 8px; | |
| height: 8px; | |
| border-radius: 50%; | |
| background: #38a169; | |
| box-shadow: 0 0 0 5px rgba(56, 161, 105, 0.13); | |
| } | |
| .hero { | |
| display: grid; | |
| grid-template-columns: 0.92fr 1.08fr; | |
| gap: 34px; | |
| align-items: stretch; | |
| } | |
| .intro { | |
| padding: 48px 22px 30px 8px; | |
| } | |
| .eyebrow { | |
| display: inline-flex; | |
| align-items: center; | |
| gap: 8px; | |
| color: var(--rust); | |
| font-size: 13px; | |
| font-weight: 800; | |
| letter-spacing: 0.1em; | |
| text-transform: uppercase; | |
| } | |
| h1 { | |
| max-width: 610px; | |
| margin: 18px 0; | |
| color: var(--forest); | |
| font-family: Georgia, "Times New Roman", serif; | |
| font-size: clamp(42px, 6vw, 72px); | |
| line-height: 0.98; | |
| letter-spacing: -0.045em; | |
| } | |
| .subtitle { | |
| max-width: 560px; | |
| margin: 0 0 28px; | |
| color: #58665d; | |
| font-size: 18px; | |
| line-height: 1.7; | |
| } | |
| .features { | |
| display: flex; | |
| flex-wrap: wrap; | |
| gap: 10px; | |
| } | |
| .chip { | |
| padding: 10px 13px; | |
| border: 1px solid rgba(82, 57, 43, 0.12); | |
| border-radius: 12px; | |
| background: rgba(255, 255, 255, 0.58); | |
| font-size: 13px; | |
| font-weight: 700; | |
| } | |
| .app-card { | |
| position: relative; | |
| overflow: hidden; | |
| padding: 28px; | |
| border: 1px solid rgba(82, 57, 43, 0.1); | |
| border-radius: 30px; | |
| background: rgba(255, 255, 255, 0.83); | |
| box-shadow: var(--shadow); | |
| backdrop-filter: blur(16px); | |
| } | |
| .card-header h2 { | |
| margin: 0 0 6px; | |
| color: var(--forest); | |
| font-size: 25px; | |
| } | |
| .card-header p { | |
| margin: 0 0 22px; | |
| color: var(--muted); | |
| } | |
| .upload-area { | |
| position: relative; | |
| display: grid; | |
| place-items: center; | |
| min-height: 280px; | |
| padding: 24px; | |
| overflow: hidden; | |
| border: 2px dashed rgba(40, 92, 67, 0.32); | |
| border-radius: 22px; | |
| background: linear-gradient(145deg, #fbf6eb, #eef2e5); | |
| cursor: pointer; | |
| transition: 0.25s ease; | |
| } | |
| .upload-area:hover, | |
| .upload-area.dragging { | |
| border-color: var(--rust); | |
| transform: translateY(-2px); | |
| } | |
| #fileInput { | |
| display: none; | |
| } | |
| .upload-content { | |
| text-align: center; | |
| } | |
| .upload-icon { | |
| margin-bottom: 10px; | |
| font-size: 48px; | |
| } | |
| .upload-content strong { | |
| display: block; | |
| color: var(--forest); | |
| font-size: 18px; | |
| } | |
| .upload-content span { | |
| display: block; | |
| margin: 7px 0 18px; | |
| color: var(--muted); | |
| font-size: 14px; | |
| } | |
| .browse-button { | |
| padding: 11px 18px; | |
| border: 0; | |
| border-radius: 12px; | |
| background: var(--forest); | |
| color: white; | |
| font-weight: 800; | |
| cursor: pointer; | |
| } | |
| #preview { | |
| display: none; | |
| width: 100%; | |
| max-height: 310px; | |
| object-fit: contain; | |
| border-radius: 16px; | |
| } | |
| .file-name { | |
| min-height: 20px; | |
| margin: 12px 0 4px; | |
| color: var(--muted); | |
| font-size: 13px; | |
| text-align: center; | |
| } | |
| .analyze-button { | |
| flex: 1; | |
| margin-top: 13px; | |
| padding: 15px; | |
| border: 0; | |
| border-radius: 15px; | |
| background: linear-gradient(135deg, var(--rust), #d8793e); | |
| color: white; | |
| font-size: 16px; | |
| font-weight: 800; | |
| cursor: pointer; | |
| box-shadow: 0 13px 25px rgba(189, 91, 49, 0.24); | |
| } | |
| .analyze-button:disabled { | |
| cursor: not-allowed; | |
| opacity: 0.45; | |
| box-shadow: none; | |
| } | |
| .action-row { | |
| display: flex; | |
| gap: 10px; | |
| align-items: stretch; | |
| } | |
| .new-image-button { | |
| margin-top: 13px; | |
| padding: 0 18px; | |
| border: 1px solid rgba(40, 92, 67, 0.25); | |
| border-radius: 15px; | |
| background: #f7f3e9; | |
| color: var(--forest); | |
| font-size: 14px; | |
| font-weight: 800; | |
| white-space: nowrap; | |
| cursor: pointer; | |
| transition: 0.2s ease; | |
| } | |
| .new-image-button:hover { | |
| background: #e9eee3; | |
| border-color: var(--forest-light); | |
| } | |
| .loading { | |
| display: none; | |
| margin-top: 18px; | |
| padding: 15px; | |
| border-radius: 14px; | |
| background: #f7efe1; | |
| color: var(--forest); | |
| text-align: center; | |
| font-weight: 700; | |
| } | |
| .result { | |
| display: none; | |
| margin-top: 20px; | |
| padding: 22px; | |
| border-radius: 20px; | |
| } | |
| .result.edible { | |
| border: 1px solid rgba(36, 117, 74, 0.22); | |
| background: #e9f5ed; | |
| } | |
| .result.poisonous { | |
| border: 1px solid rgba(169, 56, 45, 0.22); | |
| background: #faebe7; | |
| } | |
| .result-top { | |
| display: flex; | |
| justify-content: space-between; | |
| gap: 20px; | |
| align-items: center; | |
| } | |
| .result-label { | |
| color: var(--muted); | |
| font-size: 12px; | |
| font-weight: 800; | |
| letter-spacing: 0.09em; | |
| text-transform: uppercase; | |
| } | |
| .result h3 { | |
| margin: 5px 0 0; | |
| font-size: 28px; | |
| text-transform: capitalize; | |
| } | |
| .confidence { | |
| font-size: 25px; | |
| font-weight: 900; | |
| } | |
| .bar { | |
| height: 9px; | |
| margin: 18px 0 8px; | |
| overflow: hidden; | |
| border-radius: 999px; | |
| background: rgba(82, 57, 43, 0.1); | |
| } | |
| .bar-fill { | |
| width: 0; | |
| height: 100%; | |
| border-radius: inherit; | |
| background: var(--gold); | |
| transition: width 0.6s ease; | |
| } | |
| .probability { | |
| color: var(--muted); | |
| font-size: 13px; | |
| } | |
| .warning { | |
| margin-top: 16px; | |
| padding: 13px 15px; | |
| border-left: 4px solid var(--gold); | |
| border-radius: 10px; | |
| background: rgba(255, 250, 240, 0.8); | |
| color: #70502f; | |
| font-size: 13px; | |
| line-height: 1.5; | |
| } | |
| .footer { | |
| margin-top: 32px; | |
| color: #68746c; | |
| font-size: 13px; | |
| text-align: center; | |
| } | |
| .footer a { | |
| color: var(--forest); | |
| font-weight: 800; | |
| text-decoration: none; | |
| } | |
| @media (max-width: 850px) { | |
| .hero { | |
| grid-template-columns: 1fr; | |
| } | |
| .intro { | |
| padding: 28px 5px 5px; | |
| } | |
| .app-card { | |
| padding: 20px; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <main class="page"> | |
| <header class="topbar"> | |
| <div class="brand"> | |
| <div class="brand-icon">🍄</div> | |
| <span>ForestLens AI</span> | |
| </div> | |
| <div class="status"> | |
| <span class="status-dot"></span> | |
| API online | |
| </div> | |
| </header> | |
| <section class="hero"> | |
| <div class="intro"> | |
| <div class="eyebrow">🍂 Nature meets artificial intelligence</div> | |
| <h1>Discover what the forest is hiding</h1> | |
| <p class="subtitle"> | |
| Upload a clear mushroom photograph and receive an AI-powered | |
| edible or poisonous classification within seconds | |
| </p> | |
| <div class="features"> | |
| <span class="chip">📷 Image classification</span> | |
| <span class="chip">🧠 Deep learning</span> | |
| <span class="chip">⚙️ MLOps deployment</span> | |
| </div> | |
| </div> | |
| <div class="app-card"> | |
| <div class="card-header"> | |
| <h2>Analyze a mushroom</h2> | |
| <p>Upload a JPG, JPEG or PNG image.</p> | |
| </div> | |
| <div class="upload-area" id="uploadArea"> | |
| <input id="fileInput" type="file" accept="image/png,image/jpeg"> | |
| <div class="upload-content" id="uploadContent"> | |
| <div class="upload-icon">🌿</div> | |
| <strong>Drop your mushroom image here</strong> | |
| <span>or select an image from your device</span> | |
| <button class="browse-button" id="browseButton" type="button"> | |
| Choose image | |
| </button> | |
| </div> | |
| <img id="preview" alt="Selected mushroom preview"> | |
| </div> | |
| <div class="file-name" id="fileName"></div> | |
| <div class="action-row"> | |
| <button class="analyze-button" id="analyzeButton" disabled> | |
| Analyze mushroom | |
| </button> | |
| <button class="new-image-button" id="newImageButton" type="button" hidden> | |
| New image | |
| </button> | |
| </div> | |
| <div class="loading" id="loading"> | |
| 🍄 Analyzing the image… The first request may take up to 60 seconds. | |
| </div> | |
| <section class="result" id="result" aria-live="polite"> | |
| <div class="result-top"> | |
| <div> | |
| <div class="result-label">AI prediction</div> | |
| <h3 id="prediction"></h3> | |
| </div> | |
| <div class="confidence" id="confidence"></div> | |
| </div> | |
| <div class="bar"> | |
| <div class="bar-fill" id="barFill"></div> | |
| </div> | |
| <div class="probability" id="probability"></div> | |
| <div class="warning"> | |
| ⚠️ Educational use only. Never use this prediction to decide | |
| whether a mushroom is safe to eat. | |
| </div> | |
| </section> | |
| </div> | |
| </section> | |
| <footer class="footer"> | |
| Model API hosted on Render · Interface hosted on Hugging Face Spaces · | |
| <a href="https://mushroom-mlops-api.onrender.com/docs" target="_blank"> | |
| API documentation | |
| </a> | |
| </footer> | |
| </main> | |
| <script> | |
| const API_URL = "https://mushroom-mlops-api.onrender.com/predict"; | |
| const uploadArea = document.getElementById("uploadArea"); | |
| const uploadContent = document.getElementById("uploadContent"); | |
| const browseButton = document.getElementById("browseButton"); | |
| const fileInput = document.getElementById("fileInput"); | |
| const preview = document.getElementById("preview"); | |
| const fileName = document.getElementById("fileName"); | |
| const analyzeButton = document.getElementById("analyzeButton"); | |
| const newImageButton = document.getElementById("newImageButton"); | |
| const loading = document.getElementById("loading"); | |
| const result = document.getElementById("result"); | |
| let selectedFile = null; | |
| browseButton.addEventListener("click", (event) => { | |
| event.stopPropagation(); | |
| fileInput.click(); | |
| }); | |
| uploadArea.addEventListener("click", () => fileInput.click()); | |
| fileInput.addEventListener("change", () => { | |
| if (fileInput.files.length) selectFile(fileInput.files[0]); | |
| }); | |
| ["dragenter", "dragover"].forEach((eventName) => { | |
| uploadArea.addEventListener(eventName, (event) => { | |
| event.preventDefault(); | |
| uploadArea.classList.add("dragging"); | |
| }); | |
| }); | |
| ["dragleave", "drop"].forEach((eventName) => { | |
| uploadArea.addEventListener(eventName, (event) => { | |
| event.preventDefault(); | |
| uploadArea.classList.remove("dragging"); | |
| }); | |
| }); | |
| uploadArea.addEventListener("drop", (event) => { | |
| const file = event.dataTransfer.files[0]; | |
| if (file) selectFile(file); | |
| }); | |
| function selectFile(file) { | |
| if (!file.type.startsWith("image/")) { | |
| alert("Please select a valid image file."); | |
| return; | |
| } | |
| selectedFile = file; | |
| fileName.textContent = file.name; | |
| analyzeButton.disabled = false; | |
| newImageButton.hidden = false; | |
| result.style.display = "none"; | |
| const reader = new FileReader(); | |
| reader.onload = (event) => { | |
| preview.src = event.target.result; | |
| preview.style.display = "block"; | |
| uploadContent.style.display = "none"; | |
| }; | |
| reader.readAsDataURL(file); | |
| } | |
| newImageButton.addEventListener("click", () => { | |
| selectedFile = null; | |
| fileInput.value = ""; | |
| fileName.textContent = ""; | |
| preview.removeAttribute("src"); | |
| preview.style.display = "none"; | |
| uploadContent.style.display = "block"; | |
| analyzeButton.disabled = true; | |
| newImageButton.hidden = true; | |
| loading.style.display = "none"; | |
| result.style.display = "none"; | |
| result.className = "result"; | |
| }); | |
| analyzeButton.addEventListener("click", async () => { | |
| if (!selectedFile) return; | |
| analyzeButton.disabled = true; | |
| loading.style.display = "block"; | |
| result.style.display = "none"; | |
| const formData = new FormData(); | |
| formData.append("file", selectedFile); | |
| try { | |
| const response = await fetch(API_URL, { | |
| method: "POST", | |
| body: formData | |
| }); | |
| if (!response.ok) { | |
| throw new Error("The API returned an error."); | |
| } | |
| const data = await response.json(); | |
| showResult(data); | |
| } catch (error) { | |
| alert( | |
| "The prediction service could not be reached. Please wait a moment and try again." | |
| ); | |
| } finally { | |
| loading.style.display = "none"; | |
| analyzeButton.disabled = false; | |
| } | |
| }); | |
| function showResult(data) { | |
| const prediction = data.prediction.toLowerCase(); | |
| const confidencePercent = Math.round(data.confidence * 100); | |
| const poisonousPercent = Math.round(data.poisonous_probability * 100); | |
| result.className = `result ${prediction}`; | |
| document.getElementById("prediction").textContent = | |
| prediction === "edible" ? "Edible" : "Poisonous"; | |
| document.getElementById("confidence").textContent = | |
| `${confidencePercent}%`; | |
| document.getElementById("barFill").style.width = | |
| `${confidencePercent}%`; | |
| document.getElementById("probability").textContent = | |
| `Poisonous probability: ${poisonousPercent}% · Model version: ${data.model_version}`; | |
| result.style.display = "block"; | |
| result.scrollIntoView({ behavior: "smooth", block: "nearest" }); | |
| } | |
| </script> | |
| </body> | |
| </html> |