Suhani-2407's picture
Update app.py
83b25da verified
raw
history blame contribute delete
682 Bytes
import gradio as gr
import tensorflow as tf
import numpy as np
from PIL import Image
# Load model
model = tf.keras.models.load_model("Mobilenet_model.h5")
# Define class labels
class_names = ["Organic", "Recyclable", "Hazardous"]
def classify_image(image):
image = image.resize((128, 128)) # Resize to match input size
img_array = np.array(image) / 255.0
img_array = np.expand_dims(img_array, axis=0)
predictions = model.predict(img_array)
class_index = np.argmax(predictions[0])
return class_names[class_index]
gr.Interface(
fn=classify_image,
inputs=gr.Image(type="pil"),
outputs="text",
title="Waste Classification Model",
).launch()