Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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(
|
18 |
-
|
19 |
-
|
20 |
-
prediction =
|
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"
|
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)
|