kornkitti89
commited on
Commit
·
a432113
1
Parent(s):
4ac0508
init
Browse files- Requirements.txt +1 -0
- app.py +28 -0
Requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
|
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from datasets import load_dataset
|
5 |
+
from PIL import Image
|
6 |
+
import matplotlib.pyplot as plt
|
7 |
+
import numpy as np
|
8 |
+
import tensorflow as tf
|
9 |
+
from tensorflow.keras import layers
|
10 |
+
from tensorflow.keras.models import Sequential
|
11 |
+
from tensorflow.keras.models import load_model
|
12 |
+
from keras.preprocessing import image
|
13 |
+
|
14 |
+
model3 = load_model('best_beans.h5')
|
15 |
+
|
16 |
+
leaf_class=['angular_leaf_spot', 'bean_rust', 'healthy']
|
17 |
+
|
18 |
+
def classify_image(img):
|
19 |
+
img_width, img_height = 224, 224
|
20 |
+
img = image.load_img(img, target_size = (img_width, img_height))
|
21 |
+
img = image.img_to_array(img)
|
22 |
+
img = np.expand_dims(img, axis = 0)
|
23 |
+
prediction = model3.predict(img)[0]
|
24 |
+
return {leaf_class[i]: float(prediction[i]) for i in range(3)}
|
25 |
+
|
26 |
+
gr.Interface(fn=classify_image,
|
27 |
+
inputs=gr.Image( type ="filepath"),
|
28 |
+
outputs=gr.Label(num_top_classes=1)).launch(debug=True)
|