Spaces:
Runtime error
Runtime error
Create app.py
Browse files
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)
|