SHIBASHISHHH commited on
Commit
d406671
·
verified ·
1 Parent(s): a3a80f1

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import tensorflow as tf
3
+ import numpy as np
4
+ import json
5
+ from PIL import Image
6
+
7
+ model = tf.keras.models.load_model("model")
8
+
9
+ with open("class_names.json") as f:
10
+ class_names = json.load(f)
11
+
12
+ def predict(img):
13
+ img = img.resize((224,224))
14
+ img = np.array(img) / 255.0
15
+ img = np.expand_dims(img, axis=0)
16
+ pred = model.predict(img)
17
+ return class_names[np.argmax(pred)]
18
+
19
+ gr.Interface(
20
+ fn=predict,
21
+ inputs=gr.Image(type="pil"),
22
+ outputs="label",
23
+ title="Plant Disease Classifier"
24
+ ).launch()