Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
import numpy as np
|
| 4 |
-
from PIL import Image
|
| 5 |
|
| 6 |
-
# Load
|
| 7 |
-
model = load_model('your_model.keras')
|
| 8 |
|
| 9 |
-
# Streamlit
|
| 10 |
st.title('Tree Decoration Prediction')
|
| 11 |
-
st.write("Upload an image of a tree for decoration prediction:")
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
if uploaded_image
|
| 16 |
-
image = Image.
|
| 17 |
-
|
| 18 |
-
st.write("")
|
| 19 |
-
st.write("Classifying...")
|
| 20 |
-
|
| 21 |
-
# Preprocess image (resize, normalize, etc. based on your model)
|
| 22 |
-
image = image.resize((224, 224)) # Example resizing
|
| 23 |
-
image = np.array(image) / 255.0 # Example normalization
|
| 24 |
-
image = np.expand_dims(image, axis=0)
|
| 25 |
-
|
| 26 |
-
# Get prediction
|
| 27 |
-
prediction = model.predict(image)
|
| 28 |
-
st.write(f"Prediction: {'Decorated' if prediction[0][0] > 0.5 else 'Undecorated'}")
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
import streamlit as st
|
| 3 |
+
import os
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# Load the model
|
| 6 |
+
model = tf.keras.models.load_model('your_model.keras')
|
| 7 |
|
| 8 |
+
# Streamlit app interface
|
| 9 |
st.title('Tree Decoration Prediction')
|
|
|
|
| 10 |
|
| 11 |
+
# Example usage in your Streamlit app
|
| 12 |
+
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "png"])
|
| 13 |
+
if uploaded_image:
|
| 14 |
+
st.image(uploaded_image, caption="Uploaded Image.", use_column_width=True)
|
| 15 |
+
prediction = model.predict(uploaded_image)
|
| 16 |
+
st.write(f"Prediction: {prediction}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|