| import streamlit as st
|
| from tensorflow.keras.models import load_model
|
| from PIL import Image
|
| import numpy as np
|
|
|
|
|
| model = load_model('my_model2.keras')
|
|
|
| def process_image(img):
|
| img = img.resize((32, 32))
|
| img_array = np.array(img)
|
| img_normalized = img_array / 255.0
|
| img_normalized = np.expand_dims(img_normalized, axis=0)
|
| 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)
|
|
|
|
|
| st.write(f"Tahmin edilen olasılık: {prediction[0][0]:.4f}")
|
|
|
|
|
| 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]) |