Spaces:
Runtime error
Runtime error
File size: 1,831 Bytes
a52a1df 02207d5 dbff4ee 02207d5 dbff4ee a52a1df 3e0ff94 a52a1df 02207d5 3e53957 d0c09e0 b5464d3 4502f9a b79fd8e 3a0459e f993b83 8072970 f993b83 9daf8e4 f993b83 527a810 f993b83 527a810 64c77c7 bf1197c 3a0459e f993b83 273c5d0 ef836b5 9a2eda0 ef836b5 2d172bb d7cefa7 273c5d0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 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://raw.githubusercontent.com/GE-Case-Study/GEProject/main/ge_example.csv'
GE_download = requests.get(GE_url).content
### AttributeError: module 'IPython.utils.io' has no attribute 'StringIO'
#GE_data =pd.read_csv(io.StringIO(GE_download.decode('utf-8')))
def predict(dist, flight_cycle, t50_max, nc_avg, ps30_max, nrc_max, bpr_max, w32_avg):
GE_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, GE_df)
# 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); |