2Much2Code:) commited on
Commit
ebe7e61
·
1 Parent(s): 1738a4f
Files changed (6) hide show
  1. app.py +43 -0
  2. battery.JPG +0 -0
  3. jeans.jpg +0 -0
  4. model11.h5 +3 -0
  5. paper1.jpg +0 -0
  6. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ import os
5
+ import PIL
6
+ import tensorflow as tf
7
+
8
+ from tensorflow import keras
9
+ from tensorflow.keras import layers
10
+ from tensorflow.keras.models import Sequential
11
+ from tensorflow.keras.models import Sequential
12
+ from tensorflow.keras.layers import Convolution2D
13
+ from tensorflow.keras.layers import MaxPooling2D
14
+ from tensorflow.keras.layers import Flatten
15
+ from tensorflow.keras.layers import Dense
16
+ from tensorflow.keras.layers import Dropout
17
+
18
+ from tensorflow.keras.callbacks import EarlyStopping
19
+
20
+
21
+ from tensorflow.keras.models import load_model
22
+
23
+ # load model
24
+ model = load_model('model11.h5')
25
+
26
+ classnames = ['cardboard','metal','paper','plastic','trash','green-glass','white-glass','brown-glass','clothes','biological','battery','shoes']
27
+
28
+ def predict_image(img):
29
+ img_4d=img.reshape(-1,298, 384,3)
30
+ prediction=model.predict(img_4d)[0]
31
+ return {classnames[i]: float(prediction[i]) for i in range(12)}
32
+
33
+ sample_images = [
34
+ ["battery.JPG"],
35
+ ["jeans.jpg"],
36
+ ["paper1.jpg"]]
37
+
38
+
39
+ image = gr.inputs.Image(shape=(298, 384))
40
+ label = gr.outputs.Label(num_top_classes=3)
41
+
42
+ gr.Interface(fn=predict_image, inputs=image, title="Garbage Classifier",
43
+ description="This is the Model uploaded on Github trained on Dataset 11.This is just for a demo to test the deployment of Tensorflow Based Models into Gradio + Hugging Faces.",outputs=label,examples=sample_images,interpretation='default').launch(debug='True')
battery.JPG ADDED
jeans.jpg ADDED
model11.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09b7f5de5f07156815ddcd45e8ec0ea17ff998eaf6d4a35cb181c29fde6b6f67
3
+ size 153628864
paper1.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ tensorflow
2
+ numpy
3
+ requests
4
+ Pillow
5
+ matplotlib