Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -14,33 +14,31 @@ st.markdown('You can click "Browse files" multiple times until adding all images
|
|
14 |
|
15 |
#uploaded_file = st.file_uploader("Upload an image file", type="jpg", accept_multiple_files=True)
|
16 |
|
17 |
-
imageContainer = st.empty()
|
18 |
-
uploaded_file = imageContainer.file_uploader("Upload an image file", type="jpg", accept_multiple_files=True)
|
19 |
-
imageContainer.image(uploaded_file, width=100)
|
20 |
|
21 |
-
closeImage = st.button("clear all images")
|
|
|
|
|
|
|
|
|
22 |
|
23 |
img_height = 224
|
24 |
img_width = 224
|
25 |
class_names = ['Palm', 'Others']
|
26 |
|
27 |
model = tf.keras.models.load_model('model')
|
28 |
-
Generate_pred = st.button("Generate Prediction")
|
29 |
|
30 |
|
31 |
if uploaded_file is not None:
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
if closeImage:
|
44 |
-
imageContainer.empty()
|
45 |
-
if uploaded_file is not None:
|
46 |
-
del uploaded_file
|
|
|
14 |
|
15 |
#uploaded_file = st.file_uploader("Upload an image file", type="jpg", accept_multiple_files=True)
|
16 |
|
17 |
+
#imageContainer = st.empty()
|
|
|
|
|
18 |
|
19 |
+
#closeImage = st.button("clear all images")
|
20 |
+
with st.form("list", clear_on_submit=True):
|
21 |
+
uploaded_file = st.file_uploader("Upload image files", type="jpg", accept_multiple_files=True)
|
22 |
+
submitted = st.form_submit_button("submit")
|
23 |
+
st.image(uploaded_file, width=100)
|
24 |
|
25 |
img_height = 224
|
26 |
img_width = 224
|
27 |
class_names = ['Palm', 'Others']
|
28 |
|
29 |
model = tf.keras.models.load_model('model')
|
|
|
30 |
|
31 |
|
32 |
if uploaded_file is not None:
|
33 |
+
Generate_pred = st.button("Generate Prediction")
|
34 |
+
if Generate_pred:
|
35 |
+
for file in uploaded_file:
|
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)]))
|
44 |
|
|
|
|
|
|
|
|