Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,11 @@ from tensorflow.keras.preprocessing.image import img_to_array
|
|
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
|
|
|
|
|
|
|
|
|
13 |
|
14 |
img_height = 224
|
15 |
img_width = 224
|
@@ -18,15 +22,22 @@ class_names = ['Jacaranda', 'Others']
|
|
18 |
model = tf.keras.models.load_model('model')
|
19 |
|
20 |
if uploaded_file is not None:
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
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 |
-
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 image files", type="jpg", accept_multiple_files=True)
|
13 |
+
|
14 |
+
image_iterator = paginator("Select a page", uploaded_file)
|
15 |
+
indices_on_page, images_on_page = map(list, zip(*image_iterator))
|
16 |
+
st.image(images_on_page, width=100, caption=indices_on_page)
|
17 |
|
18 |
img_height = 224
|
19 |
img_width = 224
|
|
|
22 |
model = tf.keras.models.load_model('model')
|
23 |
|
24 |
if uploaded_file is not None:
|
25 |
+
#n = len(uploaded_file)
|
26 |
+
#row_size = 5
|
27 |
+
#grid = st.columns(row_size)
|
28 |
+
#col = 0
|
|
|
|
|
|
|
29 |
Generate_pred = st.button("Generate Prediction")
|
30 |
if Generate_pred:
|
31 |
+
for file in uploaded_file:
|
32 |
+
# with grid[col]:
|
33 |
+
# img = Image.open(file)
|
34 |
+
# st.image(img)
|
35 |
+
#col += 1
|
36 |
+
img = Image.open(file)
|
37 |
+
img_array = img_to_array(img)
|
38 |
+
img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
|
39 |
+
processed_image = preprocess_input(img_array)
|
40 |
+
|
41 |
+
predictions = model.predict(processed_image)
|
42 |
+
score = predictions[0]
|
43 |
+
st.markdown("Predicted class of the image {} is : {}".format(file, class_names[np.argmax(score)]))
|