VishnuEcoClim commited on
Commit
2c1be08
·
1 Parent(s): 3ce36d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -45,23 +45,25 @@ elif opt == 'Upload image via link':
45
  st.error("Please Enter a valid Image Address!")
46
 
47
 
48
- if image is not None:
49
- st.image(image, width=256, caption='Uploaded Image')
50
- if st.button('Predict'):
51
- prediction = model.predict(image[np.newaxis, ...])
 
52
 
53
- print("---------------img-array---------------------")
54
- print(image[np.newaxis, ...])
55
- print("------------summary------------------------")
56
- print(model.summary())
57
- print("------------------------------------")
58
- print(prediction)
59
 
60
- st.info('Hey! The uploaded image has been classified as " {} waste " '.format(labels[np.argmax(prediction[0], axis=-1)]))
61
-
62
- def message(img):
63
- if img == 'paper' or 'cardboard' or 'metal' or 'glass':
64
- return (" therefore your item is recyclable. Please refer to https://www.wm.com/us/en/drop-off-locations to find a drop-off location near you.")
65
- elif img == 'plastic':
66
- return ("therefore your item may have a chance of being recyclable.")
67
 
 
 
 
 
 
 
 
 
45
  st.error("Please Enter a valid Image Address!")
46
 
47
 
48
+ try:
49
+ if image is not None:
50
+ st.image(image, width=256, caption='Uploaded Image')
51
+ if st.button('Predict'):
52
+ prediction = model.predict(image[np.newaxis, ...])
53
 
54
+ print("---------------img-array---------------------")
55
+ print(image[np.newaxis, ...])
56
+ print("------------summary------------------------")
57
+ print(model.summary())
58
+ print("------------------------------------")
59
+ print(prediction)
60
 
61
+ st.info('Hey! The uploaded image has been classified as " {} waste " '.format(labels[np.argmax(prediction[0], axis=-1)]))
 
 
 
 
 
 
62
 
63
+ def message(img):
64
+ if img == 'paper' or 'cardboard' or 'metal' or 'glass':
65
+ return (" therefore your item is recyclable. Please refer to https://www.wm.com/us/en/drop-off-locations to find a drop-off location near you.")
66
+ elif img == 'plastic':
67
+ return ("therefore your item may have a chance of being recyclable.")
68
+ except:
69
+ print(f"An error occurred: {e}")