JuryMD commited on
Commit
f76ebce
·
verified ·
1 Parent(s): 2b4754d

Restore streamlit_app.py with proper code

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +57 -1
src/streamlit_app.py CHANGED
@@ -1 +1,57 @@
1
- Fix indentation and unify spaces
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from pathlib import Path
4
+ import sys
5
+
6
+ # Ensure src directory is on Python path for inference import
7
+ sys.path.append(str((Path(__file__).resolve().parent)))
8
+
9
+ from inference.model import run_inference
10
+
11
+ # Configure the Streamlit page
12
+ st.set_page_config(page_title="DeepECG PDF Demo", layout="centered")
13
+
14
+ st.title("\U0001F4AC DeepECG - PDF Analyse (Demo)")
15
+ st.markdown(
16
+ """
17
+ **Hinweis:**
18
+ Diese Demo analysiert EKG-PDFs zu Evaluations- und Forschungszwecken.
19
+ Kein Medizinprodukt. Keine Patientendaten speichern.
20
+ """
21
+ )
22
+
23
+ # File uploader for EKG PDFs
24
+ uploaded_file = st.file_uploader(
25
+ "EKG-PDF hochladen",
26
+ type=["pdf"]
27
+ )
28
+
29
+ # When a file is uploaded
30
+ if uploaded_file is not None:
31
+ st.success("PDF erfolgreich hochgeladen")
32
+
33
+ if st.button("\U0001F9E0 Analyse starten"):
34
+ with st.spinner("Analyse läuft ... bitte warten"):
35
+ # TODO: Replace this dummy signal with real PDF-to-signal extraction
36
+ dummy_signal = np.random.rand(12, 5000)
37
+
38
+ # Run inference (real model)
39
+ results = run_inference(dummy_signal)
40
+
41
+ # Display results
42
+ st.subheader("Ergebnis")
43
+
44
+ st.metric(
45
+ label="Gesamtrisiko",
46
+ value=f"{results['risk_score']} %"
47
+ )
48
+
49
+ st.subheader("Top-Diagnosen")
50
+ for diag in results["top_diagnoses"]:
51
+ st.write(f"- {diag['label']} ({diag['probability']} %)")
52
+
53
+ st.subheader("Einschätzung")
54
+ st.success(results["interpretation"])
55
+
56
+ st.subheader("Beispiel-EKG (Lead I)")
57
+ st.line_chart(dummy_signal[0])