VishnuEcoClim commited on
Commit
f434ef0
·
1 Parent(s): 94e1bda

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -41,9 +41,17 @@ elif opt == 'Upload image via link':
41
  time.sleep(4)
42
  show.empty()
43
 
44
- if image is not None:
45
- st.image(image, width=256, caption='Uploaded Image')
 
46
  if st.button('Predict'):
47
- img_array = preprocess(image)
48
- prediction = model.predict(img_array)
49
- st.info(f'Hey! The uploaded image has been classified as "{labels[np.argmax(prediction)]}" waste.')
 
 
 
 
 
 
 
 
41
  time.sleep(4)
42
  show.empty()
43
 
44
+ try:
45
+ if image is not None:
46
+ st.image(image, width = 300, caption = 'Uploaded Image')
47
  if st.button('Predict'):
48
+ img = preprocess(image)
49
+
50
+ model = model_arc()
51
+ model.load_weights("classify_model.h5")
52
+
53
+ prediction = model.predict(img[np.newaxis, ...])
54
+ st.info('Hey! The uploaded image has been classified as " {} waste " '.format(labels[np.argmax(prediction[0], axis=-1)]))
55
+ except Exception as e:
56
+ st.info(e)
57
+ pass