lily-hust commited on
Commit
8a5cd07
·
1 Parent(s): 25d762f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -20
app.py CHANGED
@@ -23,28 +23,30 @@ class_names = ['Palm', 'Others']
23
  model = tf.keras.models.load_model('model')
24
 
25
  #Generate_pred = st.button("Generate Prediction")
26
-
27
- with st.form("form", clear_on_submit=True):
28
- uploaded_file = st.file_uploader("Upload image files", type="jpg", accept_multiple_files=True)
29
- if uploaded_file is not None:
30
- st.image(uploaded_file, width=100)
31
-
32
- submitted = st.form_submit_button("Click to generate prediction")
33
 
34
- if submitted and uploaded_file is not None:
35
- st.write("Predicting!")
 
 
 
 
 
 
 
 
 
36
 
37
-
38
- for file in uploaded_file:
39
- img = Image.open(file)
40
- img_array = img_to_array(img)
41
- img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
42
- processed_image = preprocess_input(img_array)
43
 
44
- predictions = model.predict(processed_image)
45
- score = predictions[0]
46
- st.markdown("Predicted class of the image {} is : {}".format(file, class_names[np.argmax(score)]))
47
-
48
- uploaded_file = None
49
 
50
 
 
23
  model = tf.keras.models.load_model('model')
24
 
25
  #Generate_pred = st.button("Generate Prediction")
26
+ uploaded_file = None
27
+ while (uploaded_file is not None):
28
+ st.image(uploaded_file, width=100)
29
+ with st.form("form", clear_on_submit=True):
30
+ uploaded_file = st.file_uploader("Upload image files", type="jpg", accept_multiple_files=True)
31
+ if uploaded_file is not None:
32
+ st.image(uploaded_file, width=100)
33
 
34
+ submitted = st.form_submit_button("Toggle here to predict or to delete the data")
35
+
36
+ if submitted and uploaded_file is not None:
37
+
38
+
39
+
40
+ for file in uploaded_file:
41
+ img = Image.open(file)
42
+ img_array = img_to_array(img)
43
+ img_array = tf.expand_dims(img_array, axis = 0) # Create a batch
44
+ processed_image = preprocess_input(img_array)
45
 
46
+ predictions = model.predict(processed_image)
47
+ score = predictions[0]
48
+ st.markdown("Predicted class of the image {} is : {}".format(file, class_names[np.argmax(score)]))
 
 
 
49
 
50
+ uploaded_file = None
 
 
 
 
51
 
52