import gradio as gr import joblib import numpy as np # Load the model and scaler model = joblib.load("conme.pkl") scaler = joblib.load("scaler.joblib") def predict(soil_moisture, temperature, air_humidity, light_intensity): # Prepare input data input_data = np.array([[soil_moisture, temperature, air_humidity, light_intensity]]) # Scale the data std_data = scaler.transform(input_data) # Make prediction prediction = model.predict(std_data) return int(prediction[0]) # Convert prediction to int (0 or 1) # Set up Gradio interfacea iface = gr.Interface( fn=predict, inputs=[ gr.Number(label="Soil Moisture"), gr.Number(label="Temperature"), gr.Number(label="Air Humidity"), gr.Number(label="Light Intensity"), ], outputs="text", title="Plant Watering Prediction" ) if __name__ == "__main__": iface.launch()