Connection lost in local app

Summary

Hello everybody, in the app im developoing im importing an XGBoost model to make a prediction show the results in the app, but when i try to run it the app freezes and the connection is lost. I don’t know how to solve this issue.

import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objs as go
import pickle
import streamlit as st

@st.cache_resource
def load_tea():
return pickle.load(open(‘tea_LIC02.pkl’, ‘rb’))
modelo_tea = load_tea()

descripcion = st.container()
inputs = st.container()
resultados = st.container()

st.sidebar.title(‘Definiciones’)
with st.sidebar:
st.markdown(‘The metrics shown in this dashboard and the defitions below, come from the standard ANSI/ISA 18.2 - 2016.’)
st.markdown(‘CO2 equivalente (CO2e): Medida utilizada para cuantificar el efecto de calentamiento global de cada uno de los gases de efecto invernadero’)
st.markdown(‘Gases de efecto invernadero contabilizados: En esta herramienta se contabiliza la emisión de los siguientes gases de efecto invernadero por combustión de gas a tea: CO2, CO, NOx y SO2’)
st.markdown(‘Nota: Para este caso las emisiones totalizadas se hacen con base en los valroes de emisión del último trimestre medidas en la planta.’)

with descripcion:

col1, col2, col3 = st.columns([1,1,1])
with col2:
    st.write('A continuación introduzca las condiciones de flujo, presión, temperatura y composición del gas a analizar')

with inputs:
col1, col2, col3, col4, col5 = st.columns([1.2,1,1, 1, 1.2])
with col2:
flujo_tea = st.number_input(‘Flujo a tea (MMSCFD)’)
presión = st.number_input(‘Presión gas (PSI)’)
temperatura = st.number_input(‘Temperatura gas (°F)’)

with col3:
    comp_c1 = st.number_input('Composición molar C1 (%)')
    comp_c2 = st.number_input('Composición molar C2 (%)')
    comp_c3 = st.number_input('Composición molar C3 (%)')
    
with col4:
    comp_c4 = st.number_input('Composición molar C4 (%)')
    comp_c5 = st.number_input('Composición molar C5 (%)')
    comp_n2 = st.number_input('Composición molar N2 (%)')

with resultados:

flujo_tea = flujo_tea*1000000
data =pd.DataFrame([[flujo_tea, comp_c1, comp_c2, comp_c3, comp_c4, comp_c5, comp_n2]], columns=['Flujo (ft3/d)', 'C1', 'C2',
'C3', 'C4', 'C5', 'N2'])

prediccion = modelo_tea.predict(data)

st.table(prediccion)

The problem comes in the last part, where im trying to make the predicction the app freezes it says connecting and then the app disconnects.
Im using the latest version of streamlit and the XGBoost model weighs 340 kb

Hi @Juan_David_Hoyos_Boh,

Thanks for posting!

When you run it locally, does it work without the errors?

Also, please provide a link to your repo where I can clone and troubleshoot this for you further.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.