adiyamasoora01 commited on
Commit
8386370
·
verified ·
1 Parent(s): 2fa5c56

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from keras.models import load_model
4
+ from tensorflow.keras.models import load_model
5
+ from tensorflow.keras.preprocessing import image
6
+
7
+ # load model
8
+ model = load_model("intel_model.keras")
9
+
10
+ # class labels (same order as training)
11
+ class_labels = ['buildings', 'forest', 'glacier', 'mountain', 'sea', 'street']
12
+
13
+ def predict(img):
14
+ img = img.resize((150,150,3))
15
+ img_array = np.array(img) / 255.0
16
+ img_array = np.expand_dims(img_array, axis=0)
17
+
18
+ pred = model.predict(img_array)
19
+ return class_labels[np.argmax(pred)]
20
+
21
+ # UI
22
+ gr.Interface(
23
+ fn=predict,
24
+ inputs=gr.Image(type="pil"),
25
+ outputs="label",
26
+ title="Intel Image Classifier"
27
+ ).launch()