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);