lily-hust commited on
Commit
117091c
1 Parent(s): 1ae21d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -23
app.py CHANGED
@@ -20,30 +20,26 @@ st.markdown('You can click "Browse files" multiple times until adding all images
20
  img_height = 224
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
 
48
-
49
-
 
 
 
 
 
 
 
 
 
 
20
  img_height = 224
21
  img_width = 224
22
  class_names = ['Palm', 'Others']
23
+ model = tf.keras.models.load_model('model')
24
 
25
+ with st.form("my-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 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
+