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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -23,30 +23,25 @@ class_names = ['Palm', 'Others']
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
 
 
23
  model = tf.keras.models.load_model('model')
24
 
25
  #Generate_pred = st.button("Generate Prediction")
26
+ with st.form("form", clear_on_submit=True):
27
+ uploaded_file = st.file_uploader("Upload image files", type="jpg", accept_multiple_files=True)
28
+ if uploaded_file is not None:
29
+ st.image(uploaded_file, width=100)
 
 
 
30
 
31
+ submitted = st.form_submit_button("Toggle here to predict or to delete the data")
 
 
 
32
 
33
+ # if submitted and uploaded_file is not None:
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
+ # uploaded_file = None
46
 
47