Aryan-EcoClim commited on
Commit
5867cce
·
1 Parent(s): 6975406

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import urllib.request
6
  import io
7
  from utils import *
8
 
 
9
  # Initialize labels and model
10
  labels = gen_labels()
11
  model = model_arc() # Assuming this function initializes and returns a trained model
@@ -50,7 +51,7 @@ try:
50
  st.image(image, width = 256, caption = 'Uploaded Image')
51
  if st.button('Predict'):
52
  img = preprocess(image)
53
-
54
  model = model_arc()
55
  #model.load_weights("classify_model.h5")
56
 
@@ -64,6 +65,14 @@ try:
64
  print(prediction)
65
 
66
  st.info('Hey! The uploaded image has been classified as " {} waste " '.format(labels[np.argmax(prediction[0], axis=-1)]))
 
 
 
 
 
 
 
 
67
  except Exception as e:
68
  st.info(e)
69
  pass
 
6
  import io
7
  from utils import *
8
 
9
+
10
  # Initialize labels and model
11
  labels = gen_labels()
12
  model = model_arc() # Assuming this function initializes and returns a trained model
 
51
  st.image(image, width = 256, caption = 'Uploaded Image')
52
  if st.button('Predict'):
53
  img = preprocess(image)
54
+ global img
55
  model = model_arc()
56
  #model.load_weights("classify_model.h5")
57
 
 
65
  print(prediction)
66
 
67
  st.info('Hey! The uploaded image has been classified as " {} waste " '.format(labels[np.argmax(prediction[0], axis=-1)]))
68
+
69
+ if img == 'paper' or 'cardboard' or 'metal' or 'glass':
70
+ 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.")
71
+ elif img == 'plastic':
72
+ return(' therefore you item may have a chance of being recyclable. Since this model has yet to recognize types of plastics, please refer to https://www.bing.com/ck/a?!&&p=c1474e95017548dfJmltdHM9MTcwMzcyMTYwMCZpZ3VpZD0xNmNjOTFiOS1hMDgwLTY5MmItMzBmNi04MmE1YTE3ODY4NDImaW5zaWQ9NTIyMA&ptn=3&ver=2&hsh=3&fclid=16cc91b9-a080-692b-30f6-82a5a1786842&psq=what+type+of+plastic+can+be+recycled&u=a1aHR0cHM6Ly93d3cucGxhc3RpY3Nmb3JjaGFuZ2Uub3JnL2Jsb2cvd2hpY2gtcGxhc3RpYy1jYW4tYmUtcmVjeWNsZWQ&ntb=1 to check if this item can be recycled.')
73
+ else:
74
+ return('Your item is not recyclable. Please discard it safely.')
75
+
76
  except Exception as e:
77
  st.info(e)
78
  pass