Spaces:
Sleeping
Sleeping
File size: 782 Bytes
cc33eed |
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 |
import gradio as gr
import numpy as np
from tensorflow.keras.models import load_model
from PIL import Image
# Load the model
model = load_model("hf_keras_model.keras")
class_names = ['buildings', 'forest', 'glacier', 'mountain', 'sea', 'street']
def predict_image(img):
img = img.resize((150, 150))
img_array = np.array(img) / 255.0
img_array = np.expand_dims(img_array, axis=0)
preds = model.predict(img_array)[0]
confidences = {class_names[i]: float(preds[i]) for i in range(6)}
return confidences
gr.Interface(
fn=predict_image,
inputs=gr.Image(type="pil"),
outputs=gr.Label(num_top_classes=3),
title="Intel Image Classifier",
description="Upload a landscape image and get predictions (buildings, forest, glacier, etc.)"
).launch()
|