Dokkone commited on
Commit
4c5ed91
·
verified ·
1 Parent(s): cafea4d

Update pages/model_1.py

Browse files
Files changed (1) hide show
  1. pages/model_1.py +17 -14
pages/model_1.py CHANGED
@@ -19,23 +19,26 @@ with st.spinner('Model is being loaded..'):
19
  st.title("CNN Model")
20
  st.write("model loaded")
21
 
22
- # file = st.file_uploader("Upload the image to be classified", type=["jpg", "png"])
23
- # st.set_option('deprecation.showfileUploaderEncoding', False)
24
 
25
 
26
- # def upload_predict(upload_image, model):
27
- # size = (180, 180)
28
- # image = ImageOps.fit(upload_image, size, Image.LANCZOS)
29
- # image = np.asarray(image)
30
- # img = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
31
- # img_resize = cv2.resize(img, dsize=(224, 224), interpolation=cv2.INTER_CUBIC)
32
 
33
- # img_reshape = img_resize[np.newaxis, ...]
34
 
35
- # prediction = model.predict(img_reshape)
36
- # print(prediction)
37
- # return prediction
38
 
39
 
40
- # if file is None:
41
- # st.text("Please upload an image file")
 
 
 
 
19
  st.title("CNN Model")
20
  st.write("model loaded")
21
 
22
+ file = st.file_uploader("Upload the image to be classified", type=["jpg", "png"])
23
+ st.set_option('deprecation.showfileUploaderEncoding', False)
24
 
25
 
26
+ def upload_predict(upload_image, model):
27
+ size = (180, 180)
28
+ image = ImageOps.fit(upload_image, size, Image.LANCZOS)
29
+ image = np.asarray(image)
30
+ img = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
31
+ img_resize = cv2.resize(img, dsize=(224, 224), interpolation=cv2.INTER_CUBIC)
32
 
33
+ img_reshape = img_resize[np.newaxis, ...]
34
 
35
+ prediction = model.predict(img_reshape)
36
+ print(prediction)
37
+ return prediction
38
 
39
 
40
+ if file is None:
41
+ st.text("Please upload an image file")
42
+ else:
43
+ image = Image.open(file)
44
+ st.image(image, use_column_width=True)