File size: 926 Bytes
cd2900f
 
26e48e1
cd2900f
 
 
 
 
 
 
bb1a89a
 
522c997
bb1a89a
 
28ff341
cd2900f
 
 
 
 
45daa60
cd2900f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from tensorflow.keras.models import load_model
import gradio as gr
from PIL import 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)
    """images_list = []
    images_list.append(np.array(img))
    x = np.asarray(images_list)"""
    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(debug=True,enable_queue=True)