import streamlit as st import tensorflow as tf from tensorflow.keras.models import load_model from tensorflow.keras.preprocessing import image import numpy as np from PIL import Image # Load the pre-trained model model = load_model('your_trained_model_resnet50.keras') # Streamlit app title st.title("Tree Decoration Prediction") # Upload image for prediction uploaded_file = st.file_uploader("Choose a tree image", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Display uploaded image img = Image.open(uploaded_file) st.image(img, caption="Uploaded Image", use_column_width=True) # Prepare the image for prediction img = img.resize((224, 224)) # Resizing image for ResNet50 input size img_array = np.array(img) / 255.0 # Normalize img_array = np.expand_dims(img_array, axis=0) # Add batch dimension # Predict the class prediction = model.predict(img_array) # Show the prediction result if prediction[0] > 0.5: st.write("The tree is decorated!") else: st.write("The tree is undecorated!")