Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,32 @@
|
|
1 |
import streamlit as st
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
import cv2
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
import tensorflow as tf
|
6 |
+
from tensorflow.keras.applications.resnet50 import preprocess_input
|
7 |
+
from tensorflow.keras.preprocessing.image import img_to_array
|
8 |
+
|
9 |
+
st.title('Jacaranda Identification')
|
10 |
+
st.markdown('A Deep learning application to identify if a satellite image clip contains Jacaranda trees. The predicting result will be "Jacaranda", or "Others".')
|
11 |
+
|
12 |
+
uploaded_file = st.file_uploader("Upload an image file", type="jpg")
|
13 |
+
|
14 |
+
img_height = 224
|
15 |
+
img_width = 224
|
16 |
+
class_names = ['Jacaranda', 'Others']
|
17 |
+
|
18 |
+
model = tf.keras.models.load_model('model')
|
19 |
+
|
20 |
+
if uploaded_file is not None:
|
21 |
+
img = Image.open(uploaded_file)
|
22 |
+
st.image(img)
|
23 |
+
|
24 |
+
img_array = img_to_array(img)
|
25 |
+
img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
|
26 |
+
processed_image = preprocess_input(img_array)
|
27 |
+
|
28 |
+
Generate_pred = st.button("Generate Prediction")
|
29 |
+
if Generate_pred:
|
30 |
+
predictions = model.predict(processed_image)
|
31 |
+
score = predictions[0]
|
32 |
+
st.markdown("Predicted class of the image is : {}".format(class_names[np.argmax(score)]))
|