File size: 1,158 Bytes
8bf06b4
 
 
 
 
095ee36
02baffe
8bf06b4
 
c7589e5
095ee36
 
c7589e5
095ee36
02baffe
c7589e5
095ee36
 
8bf06b4
095ee36
8bf06b4
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
# Set the environment variable to use the pure-Python implementation of protobuf
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'

# Now import TensorFlow
import tensorflow as tf
import streamlit as st
from PIL import Image
import numpy as np

# Load the model
model = tf.keras.models.load_model('your_model.keras')

# Streamlit app interface
st.title('Tree Decoration Prediction')

# Example usage in your Streamlit app
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "png"])

if uploaded_image:
    # Open and display the image
    img = Image.open(uploaded_image)
    st.image(img, caption="Uploaded Image.", use_column_width=True)

    # Preprocess the image to match model input
    img = img.resize((224, 224))  # Resize if necessary to match your model input size
    img_array = np.array(img) / 255.0  # Normalize the image (if necessary)
    img_array = np.expand_dims(img_array, axis=0)  # Add batch dimension

    # Get the prediction
    prediction = model.predict(img_array)

    # Show prediction result
    st.write(f"Prediction: {prediction[0][0]}")  # Adjust according to your model's output format