Spaces:
Runtime error
Runtime error
Download app.py from JakeHolroyd/Remaining_Useful_Life: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/JakeHolroyd/Remaining_Useful_Life/resolve/refs%2Fpr%2F1/app.py
- Command line
-
hf download hf://spaces/JakeHolroyd/Remaining_Useful_Life@refs/pr/1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/JakeHolroyd/Remaining_Useful_Life/resolve/refs%2Fpr%2F1/app.py
1.64 kB
| import gradio as gr | |
| import numpy as np | |
| from datasets import load_dataset | |
| import io | |
| import pickle | |
| import requests | |
| import urllib.request | |
| import shutil | |
| import pandas as pd | |
| from pycaret.regression import * | |
| GE_url = 'https://github.com/GEProject/GEProject/blob/main/Combined_Vars.csv' | |
| download = requests.get(GE_url).content | |
| def predict(dist, flight_cycle, t50_max, nc_avg, ps30_max, nrc_max, bpr_max, w32_avg): | |
| df = pd.DataFrame.from_dict({ | |
| 'dist': [dist], 'flight_cycle': [flight_cycle], 't50_max': [t50_max], 'nc_avg': [nc_avg], 'ps30_max': [ps30_max], | |
| 'nrc_max': [nrc_max], 'bpr_max': [bpr_max], 'w32_avg': [w32_avg] | |
| }) | |
| with urllib.request.urlopen('https://github.com/GEProject/GEProject/blob/main/final_model.pkl?raw=true') as response, open('final_model.pkl', 'wb') as out_file: | |
| shutil.copyfileobj(response, out_file) | |
| model = load_model('final_model') | |
| pred = predict_model(model) | |
| return {'RUL': pred['Label']} | |
| dist = gr.inputs.Number() | |
| flight_cycle = gr.inputs.Number() | |
| t50_max = gr.inputs.Number() | |
| nc_avg = gr.inputs.Number() | |
| ps30_max = gr.inputs.Number() | |
| nrc_max = gr.inputs.Number() | |
| bpr_max = gr.inputs.Number() | |
| w32_avg = gr.inputs.Number() | |
| gr.Interface(predict, [dist, flight_cycle, t50_max, nc_avg, ps30_max, nrc_max, bpr_max, w32_avg], | |
| 'number', | |
| live=True, | |
| title = "Predicting Remaining Useful Life Using AdaBoost Regressor", | |
| description = "description test", | |
| css = 'https://bootswatch.com/5/journal/bootstrap.css').launch(debug = False); |