fiona10 commited on
Commit
65fb4e8
·
1 Parent(s): 6c90bc1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from tensorflow import keras
2
+ import gradio as gr
3
+
4
+ path_to_model = "/content/drive/MyDrive/modelPredict.h5"
5
+
6
+ model = keras.models.load_model(path_to_model)
7
+
8
+ def classify_image(inp):
9
+ # inp = load_image(inp_path)
10
+ inp = inp.reshape((-1, 224, 224, 3))
11
+ prediction = model.predict(inp).tolist()[0]
12
+ class_names = ['Bacterialblight', 'Blast', 'Brownspot', 'Tungro']
13
+ return {class_names[i]: prediction[i] for i in range(4)}
14
+
15
+ gr.Interface(fn=classify_image,
16
+ inputs=gr.inputs.Image(shape=(224, 224)),
17
+ outputs=gr.outputs.Label(num_top_classes=4),
18
+ ).launch(debug=True)