lily-hust commited on
Commit
bd6c0b6
·
1 Parent(s): 9d8d805

Update app.py

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