yassonee commited on
Commit
7bb5511
·
verified ·
1 Parent(s): ebc0e7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -25
app.py CHANGED
@@ -22,9 +22,9 @@ st.markdown("""
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
 
@@ -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
- # Disposition en deux colonnes principales
92
- col1, col2 = st.columns([1, 2])
93
 
94
- with col1:
95
- st.markdown("### 📤 Röntgenbild Upload")
 
 
 
 
 
96
  uploaded_file = st.file_uploader("", type=['png', 'jpg', 'jpeg'])
97
 
98
  if uploaded_file:
99
- conf_threshold = st.slider(
100
- "Konfidenzschwelle",
101
- min_value=0.0, max_value=1.0,
102
- value=0.60, step=0.05
103
- )
104
-
105
- with col2:
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"
@@ -133,18 +143,18 @@ def main():
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
 
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()