Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,33 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import numpy as np
|
| 3 |
-
from tensorflow.keras.models import load_model
|
| 4 |
-
from tensorflow.keras.preprocessing import image
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
st.
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
st.
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
from tensorflow.keras.models import load_model
|
| 4 |
+
from tensorflow.keras.preprocessing import image
|
| 5 |
+
from PIL import Image # Pillow'u import edin
|
| 6 |
+
|
| 7 |
+
# Modeli yükle
|
| 8 |
+
model = load_model('model.h5') # Modelinizi burada yükleyin
|
| 9 |
+
|
| 10 |
+
# Uygulama başlığı
|
| 11 |
+
st.title("🩺 Pneumonia Classification App")
|
| 12 |
+
st.write("📷 **X-ray görüntüsünü yükleyin ve pnömoni olup olmadığını kontrol edin.**")
|
| 13 |
+
|
| 14 |
+
# Dosya yükleme alanı
|
| 15 |
+
uploaded_file = st.file_uploader("🖼️ Resim yükle", type=["jpeg", "jpg", "png"])
|
| 16 |
+
|
| 17 |
+
if uploaded_file is not None:
|
| 18 |
+
# Resmi yükle ve Pillow kullanarak aç
|
| 19 |
+
img = Image.open(uploaded_file)
|
| 20 |
+
img = img.resize((150, 150)) # Resmi hedef boyuta yeniden boyutlandırın
|
| 21 |
+
st.image(img, caption='Yüklenen Resim', use_column_width=True)
|
| 22 |
+
st.write("")
|
| 23 |
+
st.write("🔍 **Tahmin ediliyor...**")
|
| 24 |
+
|
| 25 |
+
# Resmi işleyin ve model ile tahmin yapın
|
| 26 |
+
img_array = image.img_to_array(img)
|
| 27 |
+
img_array = np.expand_dims(img_array, axis=0) / 255.0 # Normalizasyon
|
| 28 |
+
|
| 29 |
+
prediction = model.predict(img_array)
|
| 30 |
+
class_names = ['🟢 Normal', '🔴 Pneumonia']
|
| 31 |
+
predicted_class = class_names[int(prediction[0] > 0.5)]
|
| 32 |
+
|
| 33 |
+
st.success(f"✅ **Tahmin: {predicted_class}**" if predicted_class == '🟢 Normal' else f"🚨 **Tahmin: {predicted_class}**")
|