MSK34's picture
Update src/app.py
d75edf0 verified
Raw
History Blame Contribute Delete
1.24 kB
import streamlit as st
import tensorflow as tf
import numpy as np
from PIL import Image
model = tf.keras.models.load_model("src/hurma_cnn_model.h5")
# Sınıf isimlerini yazıyoruz
class_names = [
"Ajwa",
"Galaxy",
"Medjool",
"Meneifi",
"Nabtat Ali",
"Rutab",
"Shaishe",
"Sokari",
"Sugaey"
]
st.title("Hurma Sınıflandırma Uygulaması")
st.write("Bir hurma görseli yükleyin, model hurma türünü tahmin etsin.")
# kullanıcıdan görsel alıyoruz
uploaded_file = st.file_uploader("Bir hurma resmi yükleyin", type=["jpg", "jpeg", "png"])
# Şimdi yüklenen resmi işleyip tahmin yapıyoruz
if uploaded_file is not None:
image = Image.open(uploaded_file).convert("RGB")
st.image(image, caption="Yüklenen Görsel", use_container_width=True)
image = image.resize((128, 128))
image_array = np.array(image) / 255.0
image_array = np.expand_dims(image_array, axis=0)
prediction = model.predict(image_array)
predicted_index = np.argmax(prediction)
predicted_class = class_names[predicted_index]
confidence = np.max(prediction) * 100
st.success(f"Tahmin Edilen Hurma Türü: {predicted_class}")
st.write(f"Güven Oranı: %{confidence:.2f}")