lily-hust commited on
Commit
cab46ec
·
1 Parent(s): 603a3b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -18
app.py CHANGED
@@ -17,28 +17,27 @@ st.markdown('You can click "Browse files" multiple times until adding all images
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
 
 
17
  #imageContainer = st.empty()
18
 
19
  #closeImage = st.button("clear all images")
 
 
 
 
 
20
  img_height = 224
21
  img_width = 224
22
  class_names = ['Palm', 'Others']
23
 
24
  model = tf.keras.models.load_model('model')
 
25
 
26
+ with st.form("list", clear_on_submit=True):
27
+ uploaded_file = st.file_uploader("Upload image files", type="jpg", accept_multiple_files=True)
28
+ submitted = st.form_submit_button("clear")
29
+ st.image(uploaded_file, width=100)
30
+
31
+ if uploaded_file is not None:
32
+ Generate_pred = st.button("Generate Prediction")
33
+ if Generate_pred:
34
+ for file in uploaded_file:
35
+ img = Image.open(file)
36
+ img_array = img_to_array(img)
37
+ img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
38
+ processed_image = preprocess_input(img_array)
39
+
40
+ predictions = model.predict(processed_image)
41
+ score = predictions[0]
42
+ st.markdown("Predicted class of the image {} is : {}".format(file, class_names[np.argmax(score)]))
43