| import streamlit as st | |
| import tensorflow as tf | |
| import numpy as np | |
| from PIL import Image | |
| # Transfer Learning modelini yüklüyoruz | |
| model = tf.keras.models.load_model("src/hurma_transfer_model.h5") | |
| # Sınıf isimlerini yazıyoruz | |
| class_names = [ | |
| "Ajwa", | |
| "Galaxy", | |
| "Medjool", | |
| "Meneifi", | |
| "Nabtat Ali", | |
| "Rutab", | |
| "Shaishe", | |
| "Sokari", | |
| "Sugaey" | |
| ] | |
| st.title("Transfer Learning ile Hurma Sınıflandırma") | |
| st.write("Bir hurma görseli yükleyin, model hurma türünü tahmin etsin.") | |
| # Görsel Yükleme | |
| uploaded_file = st.file_uploader( | |
| "Bir hurma resmi yükleyin", | |
| type=["jpg", "jpeg", "png"] | |
| ) | |
| # Şimdi yüklenen resmi modele uygun hale getirip 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((224, 224)) | |
| 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}") | |