Date_Classification / src /streamlit_app.py
Harun01's picture
Update src/streamlit_app.py
2836436 verified
raw
history blame
1.01 kB
import numpy as np
from tensorflow.keras.models import load_model
from PIL import Image
import streamlit as st
# Modeli yükle (src klasörünün içindeyse)
model = load_model('src/dates_classifier_model.h5')
def process_image(img):
img = img.resize((224, 224))
img = np.array(img) / 255.0
img = np.expand_dims(img, axis=0)
return img
st.title('Hurma Resmi Sınıflandırma')
st.write('Bir hurma resmi yükleyin, hangi tür olduğunu tahmin edelim.')
file = st.file_uploader('Bir Resim Seçin', type=['jpg', 'jpeg', 'png'])
if file is not None:
img = Image.open(file)
st.image(img, caption='Yüklenen Resim', use_column_width=True)
processed_image = process_image(img)
prediction = model.predict(processed_image)
predicted_class = np.argmax(prediction)
class_names = [
'Rutab', 'Meneifi', 'Sokari', 'Galaxy', 'Shaishe',
'Medjool', 'Ajwa', 'Nabtat Ali', 'Sugaey'
]
st.write(f'Tahmin Edilen Sınıf: **{class_names[predicted_class]}**')