Update app.py
Browse files
app.py
CHANGED
@@ -22,9 +22,9 @@ st.markdown("""
|
|
22 |
}
|
23 |
|
24 |
.stImage > img {
|
25 |
-
width:
|
26 |
height: auto !important;
|
27 |
-
max-height:
|
28 |
object-fit: contain !important;
|
29 |
}
|
30 |
|
@@ -36,6 +36,14 @@ st.markdown("""
|
|
36 |
font-size: 0.8rem !important;
|
37 |
margin: 0.2rem 0 !important;
|
38 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
</style>
|
40 |
""", unsafe_allow_html=True)
|
41 |
|
@@ -88,28 +96,30 @@ def draw_boxes(image, predictions):
|
|
88 |
def main():
|
89 |
models = load_models()
|
90 |
|
91 |
-
|
92 |
-
|
93 |
|
94 |
-
|
95 |
-
st.markdown("
|
|
|
|
|
|
|
|
|
|
|
96 |
uploaded_file = st.file_uploader("", type=['png', 'jpg', 'jpeg'])
|
97 |
|
98 |
if uploaded_file:
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
with col2:
|
106 |
-
if uploaded_file:
|
107 |
-
image = Image.open(uploaded_file)
|
108 |
|
109 |
-
|
110 |
st.markdown("### 🎯 KI-Analyse")
|
111 |
|
112 |
st.markdown("**🛡️ Der KnochenWächter**")
|
|
|
113 |
predictions_wachter = models["KnochenWächter"](image)
|
114 |
for pred in predictions_wachter:
|
115 |
score_color = "#22c55e" if pred['score'] > 0.7 else "#eab308"
|
@@ -133,18 +143,18 @@ def main():
|
|
133 |
</div>
|
134 |
""", unsafe_allow_html=True)
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
filtered_preds = [p for p in predictions_auge if p['score'] >= conf_threshold]
|
139 |
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
142 |
result_image = image.copy()
|
143 |
result_image = draw_boxes(result_image, filtered_preds)
|
144 |
-
st.image(result_image,
|
145 |
-
|
146 |
-
else:
|
147 |
-
st.info("Bitte laden Sie ein Röntgenbild hoch (JPEG, PNG)")
|
148 |
|
149 |
if __name__ == "__main__":
|
150 |
main()
|
|
|
22 |
}
|
23 |
|
24 |
.stImage > img {
|
25 |
+
width: 50% !important;
|
26 |
height: auto !important;
|
27 |
+
max-height: 120px !important;
|
28 |
object-fit: contain !important;
|
29 |
}
|
30 |
|
|
|
36 |
font-size: 0.8rem !important;
|
37 |
margin: 0.2rem 0 !important;
|
38 |
}
|
39 |
+
|
40 |
+
.center-container {
|
41 |
+
display: flex;
|
42 |
+
flex-direction: column;
|
43 |
+
align-items: center;
|
44 |
+
justify-content: center;
|
45 |
+
height: 100%;
|
46 |
+
}
|
47 |
</style>
|
48 |
""", unsafe_allow_html=True)
|
49 |
|
|
|
96 |
def main():
|
97 |
models = load_models()
|
98 |
|
99 |
+
if "uploaded" not in st.session_state:
|
100 |
+
st.session_state["uploaded"] = False
|
101 |
|
102 |
+
if not st.session_state["uploaded"]:
|
103 |
+
st.markdown("""
|
104 |
+
<div class="center-container">
|
105 |
+
<h2>📤 Röntgenbild Hochladen</h2>
|
106 |
+
<p>Bitte laden Sie ein Röntgenbild hoch, um die Analyse zu starten.</p>
|
107 |
+
</div>
|
108 |
+
""", unsafe_allow_html=True)
|
109 |
uploaded_file = st.file_uploader("", type=['png', 'jpg', 'jpeg'])
|
110 |
|
111 |
if uploaded_file:
|
112 |
+
st.session_state["uploaded"] = True
|
113 |
+
st.session_state["file"] = uploaded_file
|
114 |
+
else:
|
115 |
+
uploaded_file = st.session_state["file"]
|
116 |
+
col1, col2, col3 = st.columns([1, 1.5, 1])
|
|
|
|
|
|
|
|
|
117 |
|
118 |
+
with col1:
|
119 |
st.markdown("### 🎯 KI-Analyse")
|
120 |
|
121 |
st.markdown("**🛡️ Der KnochenWächter**")
|
122 |
+
image = Image.open(uploaded_file)
|
123 |
predictions_wachter = models["KnochenWächter"](image)
|
124 |
for pred in predictions_wachter:
|
125 |
score_color = "#22c55e" if pred['score'] > 0.7 else "#eab308"
|
|
|
143 |
</div>
|
144 |
""", unsafe_allow_html=True)
|
145 |
|
146 |
+
with col2:
|
147 |
+
st.image(image, use_column_width=True)
|
|
|
148 |
|
149 |
+
predictions_auge = models["KnochenAuge"](image)
|
150 |
+
filtered_preds = [p for p in predictions_auge if p['score'] >= 0.6]
|
151 |
+
|
152 |
+
if filtered_preds:
|
153 |
+
with col3:
|
154 |
+
st.markdown("### 👁️ Das KnochenAuge - Lokalisation")
|
155 |
result_image = image.copy()
|
156 |
result_image = draw_boxes(result_image, filtered_preds)
|
157 |
+
st.image(result_image, use_column_width=True)
|
|
|
|
|
|
|
158 |
|
159 |
if __name__ == "__main__":
|
160 |
main()
|