wizzseen commited on
Commit
0d1b4e5
·
verified ·
1 Parent(s): 38bca25
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ from tensorflow.keras.models import load_model
3
+ import gradio as gr
4
+ import tensorflow as tf
5
+ import cv2
6
+ import numpy as np
7
+ from tensorflow.keras.models import load_model
8
+
9
+ # Load the pre-trained model
10
+ new_model = load_model('cat_classifier_model.h5')
11
+
12
+ def classify_image(image_path):
13
+ img = image.load_img(image_path, target_size=(224, 224))
14
+ img_array = image.img_to_array(img)
15
+ img_array = np.expand_dims(img_array, axis=0)
16
+ img_array /= 255.0 # Rescale to values between 0 and 1 (same as during training)
17
+
18
+ prediction = model.predict(img_array)
19
+ if prediction[0][0] > 0.5:
20
+ return "not a tablet"
21
+ else:
22
+ return "is a tablet"
23
+
24
+ # Create a Gradio interface
25
+ iface = gr.Interface(
26
+ fn=classify_image,
27
+ inputs=gr.Image(),
28
+ outputs="text",
29
+ live=True,
30
+
31
+ )
32
+
33
+ # Launch the Gradio interface
34
+ iface.launch()