Spaces:
Build error
Build error
| 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 |