Spaces:
Sleeping
Sleeping
File size: 1,605 Bytes
cf19c0f 89c7879 f51433c 89c7879 f51433c 89c7879 f51433c |
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 |
import streamlit as st
import cv2
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('Jacaranda Identification')
st.markdown('A Deep learning application to identify if a satellite image clip contains Jacaranda trees. The predicting result will be "Jacaranda", or "Others".')
uploaded_file = st.file_uploader("Upload image files", type="jpg", accept_multiple_files=True)
image_iterator = paginator("Select a page", uploaded_file)
indices_on_page, images_on_page = map(list, zip(*image_iterator))
st.image(images_on_page, width=100, caption=indices_on_page)
img_height = 224
img_width = 224
class_names = ['Jacaranda', 'Others']
model = tf.keras.models.load_model('model')
if uploaded_file is not None:
#n = len(uploaded_file)
#row_size = 5
#grid = st.columns(row_size)
#col = 0
Generate_pred = st.button("Generate Prediction")
if Generate_pred:
for file in uploaded_file:
# with grid[col]:
# img = Image.open(file)
# st.image(img)
#col += 1
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)])) |