willco-afk commited on
Commit
02baffe
·
verified ·
1 Parent(s): 635e0f8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -12
app.py CHANGED
@@ -1,15 +1,28 @@
1
- import zipfile
2
- import os
3
- import tensorflow as tf
 
4
 
5
- # Path to the zipped model file in Hugging Face
6
- zip_model_path = '/app/your_trained_model.keras.zip'
7
- unzipped_model_path = '/app/your_trained_model.keras'
8
 
9
- # Unzip the model file if not already unzipped
10
- if not os.path.exists(unzipped_model_path):
11
- with zipfile.ZipFile(zip_model_path, 'r') as zip_ref:
12
- zip_ref.extractall('/app')
13
 
14
- # Load the model
15
- model = tf.keras.models.load_model(unzipped_model_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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'}")