GMARTINEZMILLA commited on
Commit
0a7e1bd
verified
1 Parent(s): 5011131

Update app.py

Browse files

Removed lottie loading

Files changed (1) hide show
  1. app.py +6 -49
app.py CHANGED
@@ -13,7 +13,6 @@ from sklearn.metrics import mean_absolute_error, mean_squared_error
13
  from joblib import dump, load
14
  from utils import recomienda_tf
15
  from utils import retroalimentacion
16
- from streamlit_lottie import st_lottie
17
  import requests
18
 
19
 
@@ -21,7 +20,7 @@ import requests
21
  st.set_page_config(page_title="DeepInsightz", page_icon=":bar_chart:", layout="wide")
22
 
23
  # Custom CSS for dynamic theme styling
24
- # Custom CSS for dynamic theme styling
25
  if st.get_option("theme.base") == "dark":
26
  background_color = "#282828"
27
  text_color = "white"
@@ -39,7 +38,6 @@ else:
39
  primary_color = '#228B22' # for positive delta in light mode
40
  negative_color = '#8B0000' # for negative delta in light mode
41
 
42
- # Load custom CSS for dynamic theme and Lottie animation
43
  st.markdown(f"""
44
  <style>
45
  body {{
@@ -62,42 +60,9 @@ st.markdown(f"""
62
  [data-testid="stSidebar"] {{
63
  background-color: {sidebar_color};
64
  }}
65
- .overlay {{
66
- position: fixed;
67
- top: 0;
68
- left: 0;
69
- width: 100%;
70
- height: 100%;
71
- display: flex;
72
- justify-content: center;
73
- align-items: center;
74
- background-color: rgba(0, 0, 0, 0.5);
75
- z-index: 1000;
76
- transition: opacity 0.5s ease;
77
- }}
78
- .overlay.hidden {{
79
- display: none;
80
- }}
81
- .overlay.active {{
82
- opacity: 1;
83
- pointer-events: all;
84
- }}
85
- .overlay.inactive {{
86
- opacity: 0;
87
- pointer-events: none;
88
- }}
89
  </style>
90
  """, unsafe_allow_html=True)
91
 
92
- # Function to show Lottie animation as an overlay
93
- def display_lottie_animation(show_animation):
94
- if show_animation:
95
- st.markdown('<div class="overlay active">', unsafe_allow_html=True)
96
- st_lottie(lottie_animation, height=300, width=300)
97
- st.markdown('</div>', unsafe_allow_html=True)
98
- else:
99
- st.markdown('<div class="overlay inactive hidden">', unsafe_allow_html=True)
100
-
101
  # Load CSV files at the top
102
  df = pd.read_csv("df_clean.csv")
103
  nombres_proveedores = pd.read_csv("nombres_proveedores.csv", sep=';')
@@ -154,13 +119,6 @@ def get_supplier_name(code):
154
  name = nombres_proveedores[nombres_proveedores['codigo'] == code]['nombre'].values
155
  return name[0] if len(name) > 0 else code
156
 
157
- def load_lottie_file(filepath: str):
158
- with open(filepath, 'r') as f:
159
- return json.load(f)
160
-
161
- # Load the animation
162
- lottie_animation = load_lottie_file("LoadingAnimation/Animation.json")
163
-
164
  def image_exists(url):
165
  """Verifica si la imagen existe en la URL proporcionada"""
166
  response = requests.head(url)
@@ -969,12 +927,11 @@ elif page == "馃挕 Recomendaci贸n de Art铆culos":
969
  with col2:
970
  # Mostrar la descripci贸n del art铆culo
971
  st.write(f"**{description}**(C贸digo: {code})")
972
-
973
- # A帽adir el art铆culo seleccionado a la cesta
974
- if code not in st.session_state['new_basket']:
975
- st.session_state['new_basket'].append(code)
976
- st_lottie(lottie_animation, height=200, width=200)
977
- st.rerun()
978
 
979
  # A帽adir un bot贸n estilizado "Calcular" con icono
980
  if st.button("馃洅 Obtener Recomendaciones"):
 
13
  from joblib import dump, load
14
  from utils import recomienda_tf
15
  from utils import retroalimentacion
 
16
  import requests
17
 
18
 
 
20
  st.set_page_config(page_title="DeepInsightz", page_icon=":bar_chart:", layout="wide")
21
 
22
  # Custom CSS for dynamic theme styling
23
+ # Streamlit detects light and dark mode automatically via the user's settings in Hugging Face Spaces
24
  if st.get_option("theme.base") == "dark":
25
  background_color = "#282828"
26
  text_color = "white"
 
38
  primary_color = '#228B22' # for positive delta in light mode
39
  negative_color = '#8B0000' # for negative delta in light mode
40
 
 
41
  st.markdown(f"""
42
  <style>
43
  body {{
 
60
  [data-testid="stSidebar"] {{
61
  background-color: {sidebar_color};
62
  }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  </style>
64
  """, unsafe_allow_html=True)
65
 
 
 
 
 
 
 
 
 
 
66
  # Load CSV files at the top
67
  df = pd.read_csv("df_clean.csv")
68
  nombres_proveedores = pd.read_csv("nombres_proveedores.csv", sep=';')
 
119
  name = nombres_proveedores[nombres_proveedores['codigo'] == code]['nombre'].values
120
  return name[0] if len(name) > 0 else code
121
 
 
 
 
 
 
 
 
122
  def image_exists(url):
123
  """Verifica si la imagen existe en la URL proporcionada"""
124
  response = requests.head(url)
 
927
  with col2:
928
  # Mostrar la descripci贸n del art铆culo
929
  st.write(f"**{description}**(C贸digo: {code})")
930
+ with st.spinner("Actualizando Cesta..."):
931
+ # A帽adir el art铆culo seleccionado a la cesta
932
+ if code not in st.session_state['new_basket']:
933
+ st.session_state['new_basket'].append(code)
934
+ st.rerun()
 
935
 
936
  # A帽adir un bot贸n estilizado "Calcular" con icono
937
  if st.button("馃洅 Obtener Recomendaciones"):