Spaces:
Runtime error
Runtime error
File size: 697 Bytes
9968120 8386370 | 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 | import gradio as gr
import numpy as np
from keras.models import load_model
from tensorflow.keras.models import load_model
from tensorflow.keras.preprocessing import image
# load model
model = load_model("intel_model.keras")
# class labels (same order as training)
class_labels = ['buildings', 'forest', 'glacier', 'mountain', 'sea', 'street']
def predict(img):
img = img.resize((150,150))
img_array = np.array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)
pred = model.predict(img_array)
return class_labels[np.argmax(pred)]
# UI
gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs="label",
title="Intel Image Classifier"
).launch() |