CoolFace
Apppublic

sifaaral/RiceClass

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
app.py38 linesDownload Raw Back to root
1import streamlit as st2from tensorflow.keras.models import load_model3from PIL import Image4import numpy as np5 6 7model=load_model('Rice.h5')8 9 10def procces_image(img):11    img = img.resize((170, 170), Image.Resampling.LANCZOS)12    img=np.array(img)13    img=img/255.0 #normalize ettik14    img=np.expand_dims(img,axis=0)15    return img16 17st.title("Pirinç Türlerinin Sınıflandırması :ear_of_rice:")18st.write("Resim Seç ve Model Yaprakların Durumunu tahmin et")19 20file=st.file_uploader('Bir Resim Seçin ',type=['jpg','jpeg','png'])21 22if file is not None:23    img = Image.open(file)24    st.image(img, caption='Yüklenen Resim')25    image = procces_image(img)26    prediction = model.predict(image)27 28    # Tahmin sonuçlarını kontrol et29    st.write("Tahmin Olasılıkları:", prediction)30 31    predicted_class = np.argmax(prediction)32    st.write("Tahmin Edilen Sınıf Indeksi:", predicted_class)33 34    class_names = ['Arborio','Basmati','Ipsala','Jasmine','Karacadag']35    if predicted_class < len(class_names):36        st.write("Tahmin Edilen Sınıf:", class_names[predicted_class])37    else:38        st.write("Geçersiz sınıf indeksi!")