Spaces:
Sleeping
Sleeping
Deploy inference service from GitHub Actions
Browse filesFiles changed (3)
- .deploy-sha+1-1
- .deploy-timestamp+1-1
- inference/app.py+44-35
172cb86e17dbfd040c14389ff22c2a3d3a0ca88ae14812d63338ee16b4bcf7841e108fd9a987ed763d
12026-03-24T20:23:29Z12026-03-24T20:28:02Z
41 unmodified lines42434445464759 unmodified lines10710810911011111222 unmodified lines13513613713813914014114214314414514614714814915015115215315415584 unmodified lines24024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727841 unmodified linesW_CONJ = float(os.getenv("ENSEMBLE_W_CONJ", "0.5"))W_NAIL = float(os.getenv("ENSEMBLE_W_NAIL", "0.5"))SPACE_CSS = """:root {59 unmodified linesasync def startup():global _PRELOAD_STATUSdef _warm_models() -> None:global _PRELOAD_STATUS_PRELOAD_STATUS = "running"22 unmodified lines@app.api_route("/", methods=["GET", "HEAD"])def root():html = """<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="refresh" content="0; url=/demo/"><meta name="viewport" content="width=device-width, initial-scale=1"><title>AnemiaScan</title></head><body><p>Redirecting to <a href="/demo/">/demo/</a> ...</p></body></html>"""return HTMLResponse(content=html, status_code=200)@app.post("/api/predict")84 unmodified linesreturn summary, result["class_probabilities"]demo = gr.Interface(fn=gradio_predict,inputs=[gr.Image(label="Conjunctiva Image (optional)", type="numpy"),gr.Image(label="Nail-bed Image (optional)", type="numpy"),],outputs=[gr.Markdown(label="Result"),gr.Label(label="Class Probabilities", num_top_classes=4),],title="AnemiaScan -- AI Anemia Screening",description=("Upload a palpebral conjunctiva and/or nail-bed image to estimate hemoglobin ""and classify anemia severity. The primary live deployment uses a fine-tuned ""EfficientNet-B4 dual-head model with MC-dropout uncertainty and Grad-CAM support. ""Tracked evaluation includes MAE, RMSE, Pearson r, AUC, F1, sensitivity, specificity, ""and Bland-Altman analysis. Saved notebook output for the current conjunctiva-only run ""reported CV MAE 0.00371 +/- 0.00108 and CV RMSE 0.00451 +/- 0.00126, but AUC and ""Pearson r were not estimable (nan) in that run. **Research tool only -- not a medical device.**\n\n""Concept, design, build, training, deployment, testing by: Dr Siddalingaiah H S, ""Professor, Community Medicine, Shridevi Institute of Medical Sciences and Research ""Hospital, Tumkur, hssling@yahoo.com, 8941087719. ORCID: 0000-0002-4771-8285."),examples=[],theme=gr.themes.Soft(primary_hue="rose",secondary_hue="amber",neutral_hue="stone",),css=SPACE_CSS,)app = gr.mount_gradio_app(app, demo, path="/demo")if __name__ == "__main__":uvicorn.run("inference.app:app", host="0.0.0.0", port=8000, reload=False)41 unmodified lines424344454647484959 unmodified lines10911011111211311411511611711811922 unmodified lines14214314414514614714814915015115215315415515615715815916016116216384 unmodified lines24824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628741 unmodified linesW_CONJ = float(os.getenv("ENSEMBLE_W_CONJ", "0.5"))W_NAIL = float(os.getenv("ENSEMBLE_W_NAIL", "0.5"))ENABLE_GRADIO = os.getenv("ENABLE_GRADIO", "1").lower() not in {"0", "false", "no"}PRELOAD_MODELS = os.getenv("PRELOAD_MODELS", "1").lower() not in {"0", "false", "no"}SPACE_CSS = """:root {59 unmodified linesasync def startup():global _PRELOAD_STATUSif not PRELOAD_MODELS:_PRELOAD_STATUS = "disabled"log.info("Background model warmup disabled by PRELOAD_MODELS=0")returndef _warm_models() -> None:global _PRELOAD_STATUS_PRELOAD_STATUS = "running"22 unmodified lines@app.api_route("/", methods=["GET", "HEAD"])def root():demo_target = "/demo/" if ENABLE_GRADIO else "/health"html = """<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="refresh" content="0; url={target}"><meta name="viewport" content="width=device-width, initial-scale=1"><title>AnemiaScan</title></head><body><p>Redirecting to <a href="{target}">{target}</a> ...</p></body></html>"""return HTMLResponse(content=html.format(target=demo_target), status_code=200)@app.post("/api/predict")84 unmodified linesreturn summary, result["class_probabilities"]if ENABLE_GRADIO:demo = gr.Interface(fn=gradio_predict,inputs=[gr.Image(label="Conjunctiva Image (optional)", type="numpy"),gr.Image(label="Nail-bed Image (optional)", type="numpy"),],outputs=[gr.Markdown(label="Result"),gr.Label(label="Class Probabilities", num_top_classes=4),],title="AnemiaScan -- AI Anemia Screening",description=("Upload a palpebral conjunctiva and/or nail-bed image to estimate hemoglobin ""and classify anemia severity. The primary live deployment uses a fine-tuned ""EfficientNet-B4 dual-head model with MC-dropout uncertainty and Grad-CAM support. ""Tracked evaluation includes MAE, RMSE, Pearson r, AUC, F1, sensitivity, specificity, ""and Bland-Altman analysis. Saved notebook output for the current conjunctiva-only run ""reported CV MAE 0.00371 +/- 0.00108 and CV RMSE 0.00451 +/- 0.00126, but AUC and ""Pearson r were not estimable (nan) in that run. **Research tool only -- not a medical device.**\n\n""Concept, design, build, training, deployment, testing by: Dr Siddalingaiah H S, ""Professor, Community Medicine, Shridevi Institute of Medical Sciences and Research ""Hospital, Tumkur, hssling@yahoo.com, 8941087719. ORCID: 0000-0002-4771-8285."),examples=[],theme=gr.themes.Soft(primary_hue="rose",secondary_hue="amber",neutral_hue="stone",),css=SPACE_CSS,)app = gr.mount_gradio_app(app, demo, path="/demo")if __name__ == "__main__":uvicorn.run("inference.app:app", host="0.0.0.0", port=8000, reload=False)
.deploy-sha+1-1
.deploy-timestamp+1-1
inference/app.py+44-35