CoolFace
Apppublic

AbraMuhara/RandomForestAgeClassificationTDDI2024Server

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
app.py31 linesDownload Raw Back to root
1import gradio as gr2import joblib3import numpy as np4import sklearn5 6 7model = joblib.load('random_forest_model.pkl')  # Update with the actual path8 9# Define a function for classification10def classify(*features):11    # Convert the input features to a 2D numpy array12    features_array = np.array([features])13    # Make a prediction14    prediction = model.predict(features_array)15    return f"Predicted Age Category: {prediction[0]}"16 17# Create the Gradio interface18iface = gr.Interface(19    fn=classify,20    inputs=[21        gr.Slider(minimum=0, maximum=100, value=50, label=f"Feature {i+1}") for i in range(15)22    ],23    outputs="text",24    title="Age Classification",25    description="Enter the 15 features to classify the age category."26)27 28# Launch the interface29iface.launch()30 31