Spaces:
Runtime error
Runtime error
Chaninder Rishi
commited on
Commit
·
3aadcd6
1
Parent(s):
c8a967d
app changes
Browse files
app.py
CHANGED
|
@@ -24,9 +24,33 @@ gr.Interface(fn=classify_image,
|
|
| 24 |
"""
|
| 25 |
|
| 26 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
def greet(name):
|
| 29 |
return "Hello " + name + "!!"
|
| 30 |
-
|
| 31 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 32 |
-
iface.launch()
|
|
|
|
|
|
| 24 |
"""
|
| 25 |
|
| 26 |
import gradio as gr
|
| 27 |
+
import tensorflow as tf
|
| 28 |
+
from tensorflow import keras
|
| 29 |
+
import requests
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
# load pre-trained model
|
| 33 |
+
model_path = "/Users/chaninderrishi/Desktop/ML/projects/waste-sorting/models/prod3"
|
| 34 |
+
pre_trained_model = keras.models.load_model(model_path)
|
| 35 |
+
|
| 36 |
+
labels = ['compost', 'e-waste', 'recycle', 'trash']
|
| 37 |
+
|
| 38 |
+
def classify_image(input):
|
| 39 |
+
prediction = pre_trained_model.predict(input)
|
| 40 |
+
confidences = {labels[i]: float(prediction[i]) for i in range(4)}
|
| 41 |
+
return confidences
|
| 42 |
|
| 43 |
+
|
| 44 |
+
iface = gr.Interface(fn=classify_image,
|
| 45 |
+
inputs=gr.Image(shape=(224, 224)),
|
| 46 |
+
outputs=gr.Label(num_top_classes=3),
|
| 47 |
+
#examples=["banana.jpg", "car.jpg"]
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
iface.launch(share=True)
|
| 51 |
+
"""
|
| 52 |
def greet(name):
|
| 53 |
return "Hello " + name + "!!"
|
|
|
|
| 54 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 55 |
+
iface.launch()
|
| 56 |
+
"""
|