chaninder commited on
Commit
e0cb95e
·
1 Parent(s): 504acbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -14,10 +14,10 @@ pre_trained_model = from_pretrained_keras(model_api_link)
14
  labels = ['compost', 'e-waste', 'recycle', 'trash']
15
 
16
 
17
- def classify_image(input):
18
- input = input.reshape((1, 224, 224, 3))
19
- input = tf.keras.applications.mobilenet_v2.preprocess_input(input)
20
- prediction = pre_trained_model.predict(input)
21
  confidences = {labels[i]: float(prediction[i]) for i in range(4)}
22
  return confidences
23
 
@@ -25,7 +25,7 @@ def classify_image(input):
25
  iface = gr.Interface(fn=classify_image,
26
  inputs=gr.Image(),
27
  outputs=gr.Label(num_top_classes=4),
28
- examples=["banana.jpg", "battery.jpg", "can.jpg", "paper.jpg"]
29
  )
30
 
31
  iface.launch(share=True)
 
14
  labels = ['compost', 'e-waste', 'recycle', 'trash']
15
 
16
 
17
+ def classify_image(inp):
18
+ inp = inp.reshape((-1, 224, 224, 3))
19
+ #inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp)
20
+ prediction = model.predict(inp).flatten()
21
  confidences = {labels[i]: float(prediction[i]) for i in range(4)}
22
  return confidences
23
 
 
25
  iface = gr.Interface(fn=classify_image,
26
  inputs=gr.Image(),
27
  outputs=gr.Label(num_top_classes=4),
28
+ examples=["banana.jpg", "battery.jpg", "can.jpg"]
29
  )
30
 
31
  iface.launch(share=True)