suddu21 commited on
Commit
450f84f
β€’
1 Parent(s): 6d04c42

Created app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ from PIL import Image
5
+ import tensorflow.keras as keras
6
+ from tensorflow.keras.models import load_model
7
+
8
+ # load model
9
+ model = load_model('model520.h5')
10
+
11
+ #prediction classes
12
+ classnames = ['paper', 'cardboard', 'plastic', 'metal', 'food', 'battery', 'shoes', 'clothes', 'glass', 'medical']
13
+
14
+ #prediction function
15
+ def predict_image(img):
16
+ img_4d=img.reshape(-1,224, 224,3)
17
+ prediction=model.predict(img_4d)[0]
18
+ return {classnames[i]: float(prediction[i]) for i in range(len(classnames))}
19
+
20
+ #Gradio interface
21
+ image = gr.inputs.Image(shape=(224, 224))
22
+ label = gr.outputs.Label(num_top_classes=3)
23
+ article="<p style='text-align: center; font-weight:bold;'>Model based on the VGG-16 CNN</p>"
24
+
25
+ gr.Interface(fn=predict_image, inputs=image, title="Garbage Classifier VGG-16",
26
+ description="This is a Garbage Classification Model Trained using VGG-16 architecture. Deployed to Hugging Face using Gradio.", outputs=label, article=article, enable_queue=True, interpretation='default').launch(share="True")