File size: 1,167 Bytes
e78ab42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
from tensorflow.keras.models import load_model
from PIL import Image
import numpy as np

# Modeli yükle
model = load_model('malaria_model.keras')

def process_image(img):
    # Resmi RGB formatına zorla (PNG'lerdeki şeffaflık kanalı hatasını önler)
    img = img.convert('RGB')
    img = img.resize((64, 64))
    img = np.array(img)
    img = img / 255.0
    img = np.expand_dims(img, axis=0)
    return img

st.title('Sıtma Resmi Sınıflandırma :microscope:')
st.write('Bir resim yükleyin, modelin sıtma olup olmadığını tahmin etmesini sağlayın!')

file = st.file_uploader('Bir resim yükle', type=['jpg', 'jpeg', 'png'])

if file is not None:
    img = Image.open(file)
    st.image(img, caption='Yüklenen Resim', use_column_width=True)

    image = process_image(img)

    prediction = model.predict(image)[0][0]

    # Ekrana modelin güven oranını yazdıralım (Hata çözmeye çok yardımcı olur)
    st.write(f"Modelin Sıtma Olma Olasılığı: %{prediction * 100:.2f}")


    predicted_class = 1 if prediction > 0.5 else 0
    class_names = ['Sıtma Yok', 'Sıtma Var']
    st.write(class_names[predicted_class])