| import streamlit as st |
| import requests |
| from PIL import Image |
| from io import BytesIO |
| import numpy as np |
| import matplotlib.pyplot as plt |
| from tensorflow.keras.models import load_model |
| from tensorflow.keras.preprocessing.image import img_to_array |
|
|
|
|
| model=load_model('HurmaModel.h5') |
|
|
|
|
| def procces_image(img): |
| img = img.resize((200, 200), Image.Resampling.LANCZOS) |
| img=np.array(img) |
| img=img/255.0 |
| img=np.expand_dims(img,axis=0) |
| return img |
|
|
| st.title("Hurma Türlerinin Sınıflandırması :palm_tree:") |
| st.write("Resim Seç ve Model Hurmaların Cinsini tahmin et") |
|
|
| 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') |
| image = procces_image(img) |
| prediction = model.predict(image) |
|
|
| |
| st.write("Tahmin Olasılıkları:", prediction) |
|
|
| predicted_class = np.argmax(prediction) |
| st.write("Tahmin Edilen Sınıf Indeksi:", predicted_class) |
|
|
| class_names = ['Ajwa','Galaxy','Medjool','Meneifi','Nabtat Ali','Rutab','Shaishe','Sokari','Sugaey'] |
| if predicted_class < len(class_names): |
| st.write("Tahmin Edilen Sınıf:", class_names[predicted_class]) |
| else: |
| st.write("Geçersiz sınıf indeksi!") |