File size: 805 Bytes
cd2900f
 
 
 
 
 
 
 
 
 
 
 
78bfd45
cd2900f
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from tensorflow.keras.models import load_model
import gradio as gr
import PIL.Image as Image
import numpy as np

model = load_model('DS11Sudhanva.h5')

classnames = ['cardboard', 'metal','paper','plastic','trash','green-glass','white-glass','brown-glass','clothes','biological','battery','shoes']

def predict(img):
    img=img.reshape(-1,298, 384,3)
    prediction = model.predict(img[0])
    return {classnames[i]: float(prediction[i]) for i in range(len(classnames)}

image = gr.inputs.Image(shape=(298, 384))
label = gr.outputs.Label(num_top_classes=3)

gr.Interface(fn=predict, inputs=image,  title="Garbage Classifier",
    description="This is a Garbage Classification Model Trained using Dataset 11 by Sud.Deployed to Hugging Faces using Gradio.",outputs=label,interpretation='default').launch()