Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -26,20 +26,20 @@ class_names = ['Palm', 'Others']
|
|
26 |
model = tf.keras.models.load_model('model')
|
27 |
Generate_pred = st.button("Generate Prediction")
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
26 |
model = tf.keras.models.load_model('model')
|
27 |
Generate_pred = st.button("Generate Prediction")
|
28 |
|
29 |
+
|
30 |
+
if uploaded_file is not None:
|
31 |
+
if Generate_pred:
|
32 |
+
for file in uploaded_file:
|
33 |
+
img = Image.open(file)
|
34 |
+
img_array = img_to_array(img)
|
35 |
+
img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
|
36 |
+
processed_image = preprocess_input(img_array)
|
37 |
+
|
38 |
+
predictions = model.predict(processed_image)
|
39 |
+
score = predictions[0]
|
40 |
+
st.markdown("Predicted class of the image {} is : {}".format(file, class_names[np.argmax(score)]))
|
41 |
|
42 |
+
if closeImage:
|
43 |
+
imageContainer.empty()
|
44 |
+
if uploaded_file is not None:
|
45 |
+
del uploaded_file
|