Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import numpy as np | |
| from pathlib import Path | |
| import sys | |
| # Ensure src directory is on Python path for inference import | |
| sys.path.append(str((Path(__file__).resolve().parent))) | |
| from inference.model import run_inference | |
| # Configure the Streamlit page | |
| st.set_page_config(page_title="DeepECG PDF Demo", layout="centered") | |
| st.title("\U0001F4AC DeepECG - PDF Analyse (Demo)") | |
| st.markdown( | |
| """ | |
| **Hinweis:** | |
| Diese Demo analysiert EKG-PDFs zu Evaluations- und Forschungszwecken. | |
| Kein Medizinprodukt. Keine Patientendaten speichern. | |
| """ | |
| ) | |
| # File uploader for EKG PDFs | |
| uploaded_file = st.file_uploader( | |
| "EKG-PDF hochladen", | |
| type=["pdf"] | |
| ) | |
| # When a file is uploaded | |
| if uploaded_file is not None: | |
| st.success("PDF erfolgreich hochgeladen") | |
| if st.button("\U0001F9E0 Analyse starten"): | |
| with st.spinner("Analyse läuft ... bitte warten"): | |
| # TODO: Replace this dummy signal with real PDF-to-signal extraction | |
| dummy_signal = np.random.rand(12, 5000) | |
| # Run inference (real model) | |
| results = run_inference(dummy_signal) | |
| # Display results | |
| st.subheader("Ergebnis") | |
| st.metric( | |
| label="Gesamtrisiko", | |
| value=f"{results['risk_score']} %" | |
| ) | |
| st.subheader("Top-Diagnosen") | |
| for diag in results["top_diagnoses"]: | |
| st.write(f"- {diag['label']} ({diag['probability']} %)") | |
| st.subheader("Einschätzung") | |
| st.success(results["interpretation"]) | |
| st.subheader("Beispiel-EKG (Lead I)") | |
| st.line_chart(dummy_signal[0]) |