Spaces:
Sleeping
Sleeping
File size: 966 Bytes
0d1b4e5 0d37720 0d1b4e5 19287b5 6371512 0d1b4e5 d242d54 3268cd3 0d1b4e5 3268cd3 0d1b4e5 19287b5 d242d54 19287b5 0d1b4e5 19287b5 0d37720 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import cv2
from tensorflow.keras.models import load_model
import gradio as gr
import tensorflow as tf
import cv2
import numpy as np
from tensorflow.keras.models import load_model
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
import numpy as np
# Load the trained model
model = load_model('cat_classifier_model.h5')
def predict_cat(image_pil):
img_resized = image_pil.resize((224, 224))
img_array = np.array(img_resized)
img_array = np.expand_dims(img_array, axis=0)
img_array = img_array / 255.0
prediction = model.predict(img_array)
if prediction[0][0] > 0.5:
return "not a tablet"
else:
return "is a tablet"
# Create a Gradio interface
iface = gr.Interface(
fn=predict_cat,
inputs=gr.Image(type='pil', label='Upload an image of a tablet'),
outputs='text'
)
# Launch the interface with share=True to create a public link
iface.launch(share=True)
|