yassonee commited on
Commit
ebc0e7a
·
verified ·
1 Parent(s): 2497a00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -35
app.py CHANGED
@@ -22,9 +22,9 @@ st.markdown("""
22
  }
23
 
24
  .stImage > img {
25
- width: 80% !important;
26
  height: auto !important;
27
- max-height: 200px !important;
28
  object-fit: contain !important;
29
  }
30
 
@@ -70,6 +70,15 @@ def draw_boxes(image, predictions):
70
  width=2
71
  )
72
 
 
 
 
 
 
 
 
 
 
73
  # Label plus compact
74
  text_bbox = draw.textbbox((box['xmin'], box['ymin']-15), label)
75
  draw.rectangle(text_bbox, fill=color)
@@ -97,47 +106,43 @@ def main():
97
  if uploaded_file:
98
  image = Image.open(uploaded_file)
99
 
100
- st.markdown("### 🔍 Meinung der KI-Experten")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
  # Analyse avec KnochenAuge (localisation)
103
- st.markdown("#### 👁️ Das KnochenAuge - Lokalisation")
104
- predictions = models["KnochenAuge"](image)
105
- filtered_preds = [p for p in predictions if p['score'] >= conf_threshold]
106
 
107
  if filtered_preds:
 
108
  result_image = image.copy()
109
  result_image = draw_boxes(result_image, filtered_preds)
110
  st.image(result_image, use_container_width=True)
111
 
112
- # Toujours afficher les résultats des autres modèles
113
- st.markdown("#### 🎯 KI-Analyse")
114
- col_left, col_right = st.columns(2)
115
-
116
- with col_left:
117
- st.markdown("**🛡️ Der KnochenWächter**")
118
- predictions = models["KnochenWächter"](image)
119
- for pred in predictions:
120
- score_color = "#22c55e" if pred['score'] > 0.7 else "#eab308"
121
- st.markdown(f"""
122
- <div class='result-box'>
123
- <span style='color: {score_color}; font-weight: 500;'>
124
- {pred['score']:.1%}
125
- </span> - {translate_label(pred['label'])}
126
- </div>
127
- """, unsafe_allow_html=True)
128
-
129
- with col_right:
130
- st.markdown("**🎓 Der RöntgenMeister**")
131
- predictions = models["RöntgenMeister"](image)
132
- for pred in predictions:
133
- score_color = "#22c55e" if pred['score'] > 0.7 else "#eab308"
134
- st.markdown(f"""
135
- <div class='result-box'>
136
- <span style='color: {score_color}; font-weight: 500;'>
137
- {pred['score']:.1%}
138
- </span> - {translate_label(pred['label'])}
139
- </div>
140
- """, unsafe_allow_html=True)
141
  else:
142
  st.info("Bitte laden Sie ein Röntgenbild hoch (JPEG, PNG)")
143
 
 
22
  }
23
 
24
  .stImage > img {
25
+ width: 70% !important;
26
  height: auto !important;
27
+ max-height: 150px !important;
28
  object-fit: contain !important;
29
  }
30
 
 
70
  width=2
71
  )
72
 
73
+ # Ajouter des points de "chaleur" aux fractures détectées
74
+ center_x = (box['xmin'] + box['xmax']) / 2
75
+ center_y = (box['ymin'] + box['ymax']) / 2
76
+ radius = 5
77
+ draw.ellipse(
78
+ [(center_x - radius, center_y - radius), (center_x + radius, center_y + radius)],
79
+ fill=color
80
+ )
81
+
82
  # Label plus compact
83
  text_bbox = draw.textbbox((box['xmin'], box['ymin']-15), label)
84
  draw.rectangle(text_bbox, fill=color)
 
106
  if uploaded_file:
107
  image = Image.open(uploaded_file)
108
 
109
+ # Toujours afficher les résultats des autres modèles
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"
116
+ st.markdown(f"""
117
+ <div class='result-box'>
118
+ <span style='color: {score_color}; font-weight: 500;'>
119
+ {pred['score']:.1%}
120
+ </span> - {translate_label(pred['label'])}
121
+ </div>
122
+ """, unsafe_allow_html=True)
123
+
124
+ st.markdown("**🎓 Der RöntgenMeister**")
125
+ predictions_meister = models["RöntgenMeister"](image)
126
+ for pred in predictions_meister:
127
+ score_color = "#22c55e" if pred['score'] > 0.7 else "#eab308"
128
+ st.markdown(f"""
129
+ <div class='result-box'>
130
+ <span style='color: {score_color}; font-weight: 500;'>
131
+ {pred['score']:.1%}
132
+ </span> - {translate_label(pred['label'])}
133
+ </div>
134
+ """, unsafe_allow_html=True)
135
 
136
  # Analyse avec KnochenAuge (localisation)
137
+ predictions_auge = models["KnochenAuge"](image)
138
+ filtered_preds = [p for p in predictions_auge if p['score'] >= conf_threshold]
 
139
 
140
  if filtered_preds:
141
+ st.markdown("#### 👁️ Das KnochenAuge - Lokalisation")
142
  result_image = image.copy()
143
  result_image = draw_boxes(result_image, filtered_preds)
144
  st.image(result_image, use_container_width=True)
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  else:
147
  st.info("Bitte laden Sie ein Röntgenbild hoch (JPEG, PNG)")
148