|
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 |
|
|
|
|
|
model = load_model('your_trained_model_resnet50.keras') |
|
|
|
|
|
st.title("Tree Decoration Prediction") |
|
|
|
|
|
uploaded_file = st.file_uploader("Choose a tree image", type=["jpg", "jpeg", "png"]) |
|
|
|
if uploaded_file is not None: |
|
|
|
img = Image.open(uploaded_file) |
|
st.image(img, caption="Uploaded Image", use_column_width=True) |
|
|
|
|
|
img = img.resize((224, 224)) |
|
img_array = np.array(img) / 255.0 |
|
img_array = np.expand_dims(img_array, axis=0) |
|
|
|
|
|
prediction = model.predict(img_array) |
|
|
|
|
|
if prediction[0] > 0.5: |
|
st.write("The tree is decorated!") |
|
else: |
|
st.write("The tree is undecorated!") |