willco-afk commited on
Commit
095ee36
·
verified ·
1 Parent(s): 537af40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -23
app.py CHANGED
@@ -1,28 +1,16 @@
 
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'}")
 
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}")