Update app.py
Browse files
app.py
CHANGED
@@ -170,14 +170,15 @@ def main():
|
|
170 |
|
171 |
with st.container():
|
172 |
st.write("### 📤 Röntgenbild hochladen")
|
173 |
-
uploaded_file = st.file_uploader("", type=['png', 'jpg', 'jpeg'])
|
174 |
|
175 |
col1, col2 = st.columns([2, 1])
|
176 |
with col1:
|
177 |
conf_threshold = st.slider(
|
178 |
"Konfidenzschwelle",
|
179 |
min_value=0.0, max_value=1.0,
|
180 |
-
value=0.60, step=0.05
|
|
|
181 |
)
|
182 |
with col2:
|
183 |
analyze_button = st.button("Analysieren")
|
@@ -196,13 +197,18 @@ def main():
|
|
196 |
# KnochenWächter
|
197 |
predictions_watcher = models["KnochenWächter"](image)
|
198 |
has_fracture = False
|
|
|
|
|
|
|
199 |
for pred in predictions_watcher:
|
200 |
if pred['score'] >= conf_threshold:
|
201 |
confidence_color = '#0066cc' if pred['score'] > 0.7 else '#ffa500'
|
202 |
-
|
|
|
203 |
has_fracture = True
|
|
|
204 |
st.markdown(f"""
|
205 |
-
<div class="result-box">
|
206 |
<span style="color: {confidence_color}; font-weight: 500;">
|
207 |
{pred['score']:.1%}
|
208 |
</span> - {translate_label(pred['label'])}
|
@@ -210,40 +216,42 @@ def main():
|
|
210 |
""", unsafe_allow_html=True)
|
211 |
|
212 |
# RöntgenMeister
|
|
|
213 |
predictions_master = models["RöntgenMeister"](image)
|
214 |
for pred in predictions_master:
|
215 |
if pred['score'] >= conf_threshold:
|
216 |
confidence_color = '#0066cc' if pred['score'] > 0.7 else '#ffa500'
|
217 |
st.markdown(f"""
|
218 |
-
<div class="result-box">
|
219 |
<span style="color: {confidence_color}; font-weight: 500;">
|
220 |
{pred['score']:.1%}
|
221 |
</span> - {translate_label(pred['label'])}
|
222 |
</div>
|
223 |
""", unsafe_allow_html=True)
|
224 |
|
225 |
-
#
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
</div>
|
236 |
-
""", unsafe_allow_html=True)
|
237 |
|
238 |
with col2:
|
239 |
-
|
240 |
predictions = models["KnochenAuge"](image)
|
241 |
-
filtered_preds = [p for p in predictions if p['score'] >= conf_threshold
|
|
|
242 |
|
243 |
-
if filtered_preds
|
|
|
244 |
result_image = draw_boxes(image, filtered_preds)
|
245 |
st.image(result_image, use_container_width=True)
|
246 |
else:
|
|
|
247 |
st.image(image, use_container_width=True)
|
248 |
|
249 |
if __name__ == "__main__":
|
|
|
170 |
|
171 |
with st.container():
|
172 |
st.write("### 📤 Röntgenbild hochladen")
|
173 |
+
uploaded_file = st.file_uploader("Bild auswählen", type=['png', 'jpg', 'jpeg'], label_visibility="collapsed")
|
174 |
|
175 |
col1, col2 = st.columns([2, 1])
|
176 |
with col1:
|
177 |
conf_threshold = st.slider(
|
178 |
"Konfidenzschwelle",
|
179 |
min_value=0.0, max_value=1.0,
|
180 |
+
value=0.60, step=0.05,
|
181 |
+
label_visibility="visible"
|
182 |
)
|
183 |
with col2:
|
184 |
analyze_button = st.button("Analysieren")
|
|
|
197 |
# KnochenWächter
|
198 |
predictions_watcher = models["KnochenWächter"](image)
|
199 |
has_fracture = False
|
200 |
+
max_fracture_score = 0
|
201 |
+
|
202 |
+
st.write("#### 🛡️ KnochenWächter")
|
203 |
for pred in predictions_watcher:
|
204 |
if pred['score'] >= conf_threshold:
|
205 |
confidence_color = '#0066cc' if pred['score'] > 0.7 else '#ffa500'
|
206 |
+
label_lower = pred['label'].lower()
|
207 |
+
if 'fracture' in label_lower:
|
208 |
has_fracture = True
|
209 |
+
max_fracture_score = max(max_fracture_score, pred['score'])
|
210 |
st.markdown(f"""
|
211 |
+
<div class="result-box" style="color: #1a1a1a;">
|
212 |
<span style="color: {confidence_color}; font-weight: 500;">
|
213 |
{pred['score']:.1%}
|
214 |
</span> - {translate_label(pred['label'])}
|
|
|
216 |
""", unsafe_allow_html=True)
|
217 |
|
218 |
# RöntgenMeister
|
219 |
+
st.write("#### 🎓 RöntgenMeister")
|
220 |
predictions_master = models["RöntgenMeister"](image)
|
221 |
for pred in predictions_master:
|
222 |
if pred['score'] >= conf_threshold:
|
223 |
confidence_color = '#0066cc' if pred['score'] > 0.7 else '#ffa500'
|
224 |
st.markdown(f"""
|
225 |
+
<div class="result-box" style="color: #1a1a1a;">
|
226 |
<span style="color: {confidence_color}; font-weight: 500;">
|
227 |
{pred['score']:.1%}
|
228 |
</span> - {translate_label(pred['label'])}
|
229 |
</div>
|
230 |
""", unsafe_allow_html=True)
|
231 |
|
232 |
+
# Probabilités actualisées
|
233 |
+
if max_fracture_score > 0:
|
234 |
+
st.write("#### 📊 Wahrscheinlichkeit")
|
235 |
+
no_fracture_prob = 1 - max_fracture_score
|
236 |
+
st.markdown(f"""
|
237 |
+
<div class="result-box" style="color: #1a1a1a;">
|
238 |
+
Knochenbruch: <strong style="color: #0066cc">{max_fracture_score:.1%}</strong><br>
|
239 |
+
Kein Knochenbruch: <strong style="color: #ffa500">{no_fracture_prob:.1%}</strong>
|
240 |
+
</div>
|
241 |
+
""", unsafe_allow_html=True)
|
|
|
|
|
242 |
|
243 |
with col2:
|
244 |
+
# Vérification et localisation des fractures
|
245 |
predictions = models["KnochenAuge"](image)
|
246 |
+
filtered_preds = [p for p in predictions if p['score'] >= conf_threshold
|
247 |
+
and 'fracture' in p['label'].lower()]
|
248 |
|
249 |
+
if filtered_preds:
|
250 |
+
st.write("#### 🎯 Fraktur Lokalisation")
|
251 |
result_image = draw_boxes(image, filtered_preds)
|
252 |
st.image(result_image, use_container_width=True)
|
253 |
else:
|
254 |
+
st.write("#### 🖼️ Röntgenbild")
|
255 |
st.image(image, use_container_width=True)
|
256 |
|
257 |
if __name__ == "__main__":
|