Spaces:
Runtime error
Runtime error
Download app.py from ramspheldonyango/Smart_Solar_Drying_System: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/ramspheldonyango/Smart_Solar_Drying_System/resolve/main/app.py
- Command line
-
hf download hf://spaces/ramspheldonyango/Smart_Solar_Drying_System/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ramspheldonyango/Smart_Solar_Drying_System/resolve/main/app.py
1.55 kB
| import gradio as gr | |
| from flask import Flask, render_template, request | |
| import joblib | |
| import numpy as np | |
| import pickle | |
| app = Flask(__name__) | |
| # Load models | |
| regressor = joblib.load('model/regressor_model.pkl') | |
| classifier = joblib.load('model/classifier_model.pkl') | |
| def home(): | |
| return render_template('index.html') | |
| def regression(): | |
| return render_template('regression.html') | |
| def classification(): | |
| return render_template('classification.html') | |
| def predict_regression(): | |
| try: | |
| input_data = [float(x) for x in request.form.values()] | |
| features = np.array([input_data]) | |
| prediction = regressor.predict(features)[0] | |
| return render_template('regression.html', prediction_text=f'📈 Predicted Value: {prediction:.2f}') | |
| except Exception as e: | |
| return render_template('regression.html', prediction_text=f"⚠️ Error: {str(e)}") | |
| def predict_classification(): | |
| try: | |
| input_data = [float(x) for x in request.form.values()] | |
| features = np.array([input_data]) | |
| prediction = classifier.predict(features)[0] | |
| return render_template('classification.html', prediction_text=f'🎯 Predicted Class: {int(prediction)}') | |
| except Exception as e: | |
| return render_template('classification.html', prediction_text=f"⚠️ Error: {str(e)}") | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |