import streamlit as st from tensorflow.keras.models import load_model from PIL import Image import numpy as np # Modelin yüklenmesi model = load_model('my_model2.keras') def process_image(img): img = img.resize((32, 32)) # Malaria datasetindeki tipik boyut (örneğin 128x128) img_array = np.array(img) img_normalized = img_array / 255.0 # Normalizasyon img_normalized = np.expand_dims(img_normalized, axis=0) # Boyut ekleme return img_normalized st.title("Malaria Parazit Sınıflandırma") st.write("Bir resim yükleyin ve modelin parazit olup olmadığını tahmin etmesine izin verin.") file = st.file_uploader('Bir Resim Seç', type=['jpg', 'jpeg', 'png']) if file is not None: img = Image.open(file) st.image(img, caption='Yüklenen Resim') image = process_image(img) prediction = model.predict(image) # Tahmin edilen olasılığı yazdır st.write(f"Tahmin edilen olasılık: {prediction[0][0]:.4f}") # Tahmini sınıf etiketine dönüştür threshold = 0.5 prediction_class = 1 if prediction[0][0] > threshold else 0 class_names = ['Parazit Yok', 'Parazit Var'] st.write("Sonuç:", class_names[prediction_class])