Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,15 +27,15 @@ html_content = f"""
|
|
| 27 |
st.markdown(html_content, unsafe_allow_html=True)
|
| 28 |
|
| 29 |
# Cache models to prevent re-loading on every run
|
| 30 |
-
|
| 31 |
def load_translation_model(model_name):
|
| 32 |
return T5ForConditionalGeneration.from_pretrained(model_name)
|
| 33 |
|
| 34 |
-
|
| 35 |
def load_tapex_model():
|
| 36 |
return BartForConditionalGeneration.from_pretrained("microsoft/tapex-large-finetuned-wtq")
|
| 37 |
|
| 38 |
-
|
| 39 |
def load_tapex_tokenizer():
|
| 40 |
return TapexTokenizer.from_pretrained("microsoft/tapex-large-finetuned-wtq")
|
| 41 |
|
|
@@ -111,8 +111,8 @@ def apply_prophet(df_clean):
|
|
| 111 |
return pd.DataFrame()
|
| 112 |
|
| 113 |
# Debugging: Check structure of df_clean
|
| 114 |
-
st.write("Estrutura do DataFrame df_clean:")
|
| 115 |
-
st.write(df_clean)
|
| 116 |
|
| 117 |
# Criar um DataFrame vazio para armazenar todas as anomalias
|
| 118 |
all_anomalies = pd.DataFrame()
|
|
@@ -127,8 +127,8 @@ def apply_prophet(df_clean):
|
|
| 127 |
})
|
| 128 |
|
| 129 |
# Debugging: Check the data passed into Prophet
|
| 130 |
-
st.write(f"Dados para Prophet - Grupo {row['Rotulo']}:")
|
| 131 |
-
st.write(data)
|
| 132 |
|
| 133 |
# Remove rows where 'y' is zero or missing
|
| 134 |
data = data[data['y'] > 0].dropna().reset_index(drop=True)
|
|
@@ -156,14 +156,16 @@ def apply_prophet(df_clean):
|
|
| 156 |
anomalies = forecast[(forecast['real'] < forecast['yhat_lower']) | (forecast['real'] > forecast['yhat_upper'])]
|
| 157 |
|
| 158 |
# Debugging: Check the anomalies detected
|
| 159 |
-
st.write(f"Anomalias detectadas para o grupo {row['Rotulo']}:")
|
| 160 |
-
st.write(anomalies)
|
| 161 |
|
| 162 |
# Add group label and append anomalies to all_anomalies DataFrame
|
| 163 |
anomalies['group'] = row['Rotulo']
|
| 164 |
all_anomalies = pd.concat([all_anomalies, anomalies[['ds', 'real', 'group']]], ignore_index=True)
|
| 165 |
|
| 166 |
# Return the dataframe of all anomalies
|
|
|
|
|
|
|
| 167 |
return all_anomalies
|
| 168 |
|
| 169 |
# Initialize session states
|
|
|
|
| 27 |
st.markdown(html_content, unsafe_allow_html=True)
|
| 28 |
|
| 29 |
# Cache models to prevent re-loading on every run
|
| 30 |
+
#@st.cache_resource
|
| 31 |
def load_translation_model(model_name):
|
| 32 |
return T5ForConditionalGeneration.from_pretrained(model_name)
|
| 33 |
|
| 34 |
+
#@st.cache_resource
|
| 35 |
def load_tapex_model():
|
| 36 |
return BartForConditionalGeneration.from_pretrained("microsoft/tapex-large-finetuned-wtq")
|
| 37 |
|
| 38 |
+
#@st.cache_resource
|
| 39 |
def load_tapex_tokenizer():
|
| 40 |
return TapexTokenizer.from_pretrained("microsoft/tapex-large-finetuned-wtq")
|
| 41 |
|
|
|
|
| 111 |
return pd.DataFrame()
|
| 112 |
|
| 113 |
# Debugging: Check structure of df_clean
|
| 114 |
+
#st.write("Estrutura do DataFrame df_clean:")
|
| 115 |
+
#st.write(df_clean)
|
| 116 |
|
| 117 |
# Criar um DataFrame vazio para armazenar todas as anomalias
|
| 118 |
all_anomalies = pd.DataFrame()
|
|
|
|
| 127 |
})
|
| 128 |
|
| 129 |
# Debugging: Check the data passed into Prophet
|
| 130 |
+
#st.write(f"Dados para Prophet - Grupo {row['Rotulo']}:")
|
| 131 |
+
#st.write(data)
|
| 132 |
|
| 133 |
# Remove rows where 'y' is zero or missing
|
| 134 |
data = data[data['y'] > 0].dropna().reset_index(drop=True)
|
|
|
|
| 156 |
anomalies = forecast[(forecast['real'] < forecast['yhat_lower']) | (forecast['real'] > forecast['yhat_upper'])]
|
| 157 |
|
| 158 |
# Debugging: Check the anomalies detected
|
| 159 |
+
#st.write(f"Anomalias detectadas para o grupo {row['Rotulo']}:")
|
| 160 |
+
#st.write(anomalies)
|
| 161 |
|
| 162 |
# Add group label and append anomalies to all_anomalies DataFrame
|
| 163 |
anomalies['group'] = row['Rotulo']
|
| 164 |
all_anomalies = pd.concat([all_anomalies, anomalies[['ds', 'real', 'group']]], ignore_index=True)
|
| 165 |
|
| 166 |
# Return the dataframe of all anomalies
|
| 167 |
+
st.write(f"Concluída a aplicação do modelo de série tempotal")
|
| 168 |
+
st.write(all_anomalies.head())
|
| 169 |
return all_anomalies
|
| 170 |
|
| 171 |
# Initialize session states
|