lily-hust commited on
Commit
6c9a152
·
1 Parent(s): dbc362b

Update app.py

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