CoolFace
Apppublic

wide11/pothole_detection

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
app.py33 linesDownload Raw Back to root
1import gradio as gr2import gdown3import tensorflow as tf4import numpy as np5import os6 7# ๐Ÿ”ฝ Step 1: Download the .h5 model from Google Drive8file_id = '1-caQCrJBFlSx2TTCIthsFMAkTZtd2igx'  # <-- Replace with your actual file ID9output = 'model.h5'10 11if not os.path.exists(output):12    gdown.download(f'https://drive.google.com/uc?id={file_id}', output, quiet=False)13 14# โœ… Step 2: Load the model15model = tf.keras.models.load_model(output)16 17# ๐Ÿง  Step 3: Define prediction function18def predict(input_str):19    try:20        features = [float(x) for x in input_str.split(',')]21        features_array = np.array([features])22        prediction = model.predict(features_array)23        return str(prediction[0])24    except Exception as e:25        return f"Error: {str(e)}"26 27# ๐ŸŽจ Step 4: Create Gradio interface28gr.Interface(29    fn=predict,30    inputs=gr.Textbox(label="Input features (comma-separated)"),31    outputs=gr.Textbox(label="Prediction")32).launch()33