comeis/grapevine_leaf
0
1import streamlit as st2import numpy as np3import pandas as pd4import cv25from keras.models import load_model6from tensorflow.keras.preprocessing import image7 8# Load the model9model = load_model('grapevine_model.h5')10 11# Set the title and header12st.title("Grapevine Leaves Classifier")13st.markdown("""14 Welcome to the Grapevine Leaves Classifier! ๐15 16 Upload an image of a grapevine leaf, and our model will predict its species.17""")18 19# File uploader20uploaded_file = st.file_uploader("Upload a grapevine leaf image...", type=["jpg", "jpeg", "png"])21 22if uploaded_file is not None:23 # Read the uploaded image24 img = image.load_img(uploaded_file, target_size=(170, 170))25 img_array = image.img_to_array(img)26 img_array = np.expand_dims(img_array, axis=0) / 255.0 # Normalize27 28 # Make a prediction29 predictions = model.predict(img_array)30 class_label = np.argmax(predictions[0]) # Get the index of the class with the highest prediction31 class_names = ['Ak', 'Ala_Idris', 'Buzgulu', 'Dimnit', 'Nazli'] # Class names32 predicted_class = class_names[class_label]33 34 # Display the result35 st.image(uploaded_file, caption="Uploaded Image", use_column_width=True, channels="RGB")36 st.write(f"**Prediction:** {predicted_class}")37 38# Style the app39st.markdown("""40 <style>41 .stApp {42 background-color: #FFA500;43 }44 .stTitle {45 color: #4CAF50;46 }47 .stMarkdown {48 font-size: 18px;49 color: #333;50 }51 </style>52""", unsafe_allow_html=True)