CoolFace
Apppublic

Project20255/Betel_Leaf

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py33 linesDownload Raw Back to root
1import gradio as gr2import tensorflow as tf3import numpy as np4from PIL import Image5 6MODEL_PATH = "model.h5"  # your file name7 8# Load model from .h59model = tf.keras.models.load_model(MODEL_PATH, compile=False)10 11def predict(image):12    # Preprocess image13    img = image.resize((224, 224))  # change to match your model input14    img_array = np.array(img) / 255.015    img_array = np.expand_dims(img_array, axis=0)16 17    # Make prediction18    preds = model.predict(img_array)19    class_idx = np.argmax(preds)20    confidence = float(np.max(preds))21 22    return f"Predicted Class: {class_idx} | Confidence: {confidence:.2f}"23 24# Gradio interface25iface = gr.Interface(26    fn=predict,27    inputs=gr.Image(type="pil"),28    outputs="text",29    title="Betel Leaf Disease Detection"30)31 32iface.launch()33