Spaces:
Sleeping
Sleeping
Delete deploypalm.py
Browse files- deploypalm.py +0 -36
deploypalm.py
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import streamlit as st
|
3 |
-
import cv2
|
4 |
-
from PIL import Image
|
5 |
-
import numpy as np
|
6 |
-
import tensorflow as tf
|
7 |
-
from tensorflow.keras.applications.resnet50 import preprocess_input
|
8 |
-
from tensorflow.keras.preprocessing.image import img_to_array
|
9 |
-
|
10 |
-
st.title('Palm Identification')
|
11 |
-
st.markdown("This is a Deep Learning application to identify if a satellite image clip contains Palm trees.\n")
|
12 |
-
st.markdown('The predicting result will be "Palm", or "Others".')
|
13 |
-
st.markdown('You can click "Brows files" multiple times until adding all images before generating prediction.\n')
|
14 |
-
|
15 |
-
uploaded_file = st.file_uploader("Upload an image file", type="jpg")
|
16 |
-
st.image(uploaded_file, width=100)
|
17 |
-
|
18 |
-
img_height = 224
|
19 |
-
img_width = 224
|
20 |
-
class_names = ['Palm', 'Others']
|
21 |
-
|
22 |
-
model = tf.keras.models.load_model('model')
|
23 |
-
|
24 |
-
if uploaded_file is not None:
|
25 |
-
Generate_pred = st.button("Generate Prediction")
|
26 |
-
if Generate_pred:
|
27 |
-
for file in uploaded_file:
|
28 |
-
img = Image.open(file)
|
29 |
-
img_array = img_to_array(img)
|
30 |
-
img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
|
31 |
-
processed_image = preprocess_input(img_array)
|
32 |
-
|
33 |
-
predictions = model.predict(processed_image)
|
34 |
-
score = predictions[0]
|
35 |
-
st.markdown("Predicted class of the image {} is : {}".format(file, class_names[np.argmax(score)]))
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|