hakandeniz47's picture
Update app.py
409e720 verified
Raw History Blame Contribute Delete
878 Bytes
#import libraries
import streamlit as st
from tensorflow.keras.models import load_model
from PIL import Image
import numpy as np
import cv2
model=load_model('src/date_fruit_colab.keras')
def process_image(img):
img=img.resize((150,150))
img=np.array(img)
img=img/255.0
img=np.expand_dims(img,axis=0)
return img
st.title("Date Fruit Classification:date_tree:")
st.write("Pick a picture and let the model predict the type of date")
file=st.file_uploader('Pick a picture',type=['jpg','jpeg','png','JPG'])
if file is not None:
img=Image.open(file)
st.image(img,caption='loaded picture')
image= process_image(img)
prediction=model.predict(image)
predicted_class=np.argmax(prediction)
class_names=['Ajwa', 'Galaxy', 'Medjool', 'Meneifi', 'Nabtat Ali', 'Rutab', 'Shaishe', 'Sokari', 'Sugaey']
st.write(class_names[predicted_class])