Spaces:
Running
Running
File size: 2,256 Bytes
74a3a30 11ef4b4 66f72c6 11ef4b4 74a3a30 7f5deb9 74a3a30 3833e7c 74a3a30 128ad4b f93980b 603a3b6 f93980b 603a3b6 74a3a30 117091c 74a3a30 66f72c6 11ef4b4 6c9a152 11ef4b4 1fb43d3 11ef4b4 8a5cd07 d8b3938 8a5cd07 d8b3938 1fb43d3 d8b3938 6c9a152 d8b3938 25d762f 117091c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import streamlit as st
from random import randint
#from .session_state import get_session_state
import cv2
import pandas
from PIL import Image
import numpy as np
import tensorflow as tf
from tensorflow.keras.applications.resnet50 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
st.title('Palm Identification')
st.markdown("This is a Deep Learning application to identify if a satellite image clip contains Palm trees.\n")
st.markdown('The predicting result will be "Palm", or "Others".')
st.markdown('You can click "Browse files" multiple times until adding all images before generating prediction.\n')
#uploaded_file = st.file_uploader("Upload an image file", type="jpg", accept_multiple_files=True)
#imageContainer = st.empty()
#closeImage = st.button("clear all images")
img_height = 224
img_width = 224
class_names = ['Palm', 'Others']
model = tf.keras.models.load_model('model')
state = st.session_state.get_session_state()
if not state.widget_key:
state.widget_key = str(randint(1000, 100000000))
uploaded_file = st.file_uploader(
"Choose a file", accept_multiple_files=True, key=state.widget_key)
if st.button('clear uploaded_file'):
state.widget_key = str(randint(1000, 100000000))
state.sync()
#Generate_pred = st.button("Generate Prediction")
#with st.form("form", clear_on_submit=True):
# uploaded_file = st.file_uploader("Upload image files", type="jpg", accept_multiple_files=True)
# if uploaded_file is not None:
# st.image(uploaded_file, width=100)
# submitted = st.form_submit_button("Toggle here to predict or to delete the data")
# if submitted and uploaded_file is not None:
# for file in uploaded_file:
# img = Image.open(file)
# img_array = img_to_array(img)
# img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
# processed_image = preprocess_input(img_array)
# predictions = model.predict(processed_image)
# score = predictions[0]
# st.markdown("Predicted class of the image {} is : {}".format(file, class_names[np.argmax(score)]))
# uploaded_file = None
|