Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,28 @@
|
|
| 1 |
-
import
|
| 2 |
-
import
|
| 3 |
-
import
|
|
|
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
unzipped_model_path = '/app/your_trained_model.keras'
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
zip_ref.extractall('/app')
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from tensorflow.keras.models import load_model
|
| 3 |
+
import numpy as np
|
| 4 |
+
from PIL import Image
|
| 5 |
|
| 6 |
+
# Load your trained model
|
| 7 |
+
model = load_model('your_model.keras')
|
|
|
|
| 8 |
|
| 9 |
+
# Streamlit UI
|
| 10 |
+
st.title('Tree Decoration Prediction')
|
| 11 |
+
st.write("Upload an image of a tree for decoration prediction:")
|
|
|
|
| 12 |
|
| 13 |
+
uploaded_image = st.file_uploader("Choose an image...", type="jpg")
|
| 14 |
+
|
| 15 |
+
if uploaded_image is not None:
|
| 16 |
+
image = Image.open(uploaded_image)
|
| 17 |
+
st.image(image, caption='Uploaded Image.', use_column_width=True)
|
| 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'}")
|