CosmickVisions commited on
Commit
d880fa5
ยท
verified ยท
1 Parent(s): 2c92d1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -159,6 +159,7 @@ st.markdown(
159
  h1, h2, h3, h4, h5, h6 {
160
  color: #00f7ff !important; /* Headings to cyan */
161
  }
 
162
  /* Styles for loader */
163
  .loader {
164
  border: 5px solid #f3f3f3;
@@ -168,6 +169,7 @@ st.markdown(
168
  height: 30px;
169
  animation: spin 2s linear infinite;
170
  }
 
171
  @keyframes spin {
172
  0% { transform: rotate(0deg); }
173
  100% { transform: rotate(360deg); }
@@ -180,18 +182,18 @@ st.markdown(
180
  # --- Image Loading ---
181
  @st.cache_data(ttl=3600)
182
  async def load_image(image_url):
183
- """Loads an image from a URL asynchronously."""
184
  try:
185
  response = requests.get(image_url, stream=True)
186
  response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
187
- return BytesIO(response.content) # Return image data as a BytesIO object
188
  except requests.exceptions.RequestException as e:
189
  st.error(f"Error loading image: {e}")
190
- return None # Handle errors gracefully
191
 
192
  async def set_background():
193
  """Sets the background image."""
194
- image_url = "https://images.unsplash.com/photo-1504821618514-8c1b6e408ca8?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1949&q=80" # Replace with actual URL
195
  image_data = await load_image(image_url)
196
 
197
  if image_data:
@@ -199,7 +201,7 @@ async def set_background():
199
  f"""
200
  <style>
201
  .stApp {{
202
- background-image: url(data:image/{"jpeg"};base64,{image_data.getvalue().hex()});
203
  background-size: cover;
204
  }}
205
  </style>
@@ -277,8 +279,7 @@ def animated_progress_bar(progress_var, message="Processing..."):
277
  time.sleep(0.01) # reduced sleep timer as its getting too long
278
 
279
  # --- Main App Logic ---
280
-
281
- if app_mode == "Data Upload": #Check
282
  st.title("๐Ÿ“ค Data Upload & Analysis")
283
 
284
  uploaded_file = st.file_uploader("Upload Dataset", type=["csv", "xlsx"])
@@ -304,7 +305,7 @@ if app_mode == "Data Upload": #Check
304
  pr = generate_profile(df)
305
  st_profile_report(pr)
306
 
307
- elif app_mode == "Smart Cleaning": #Check
308
  st.title("๐Ÿงผ Intelligent Data Cleaning")
309
 
310
  if st.session_state.raw_data is not None:
@@ -413,7 +414,7 @@ elif app_mode == "Smart Cleaning": #Check
413
  with col2:
414
  st.write("Cleaned Data", df.head(3))
415
 
416
- elif app_mode == "Advanced EDA": #Check
417
  st.title("๐Ÿ” Advanced Exploratory Analysis")
418
 
419
  if st.session_state.cleaned_data is not None:
@@ -475,7 +476,7 @@ elif app_mode == "Advanced EDA": #Check
475
  except Exception as e:
476
  st.error(f"Error generating plot: {e}")
477
 
478
- elif app_mode == "Model Training": #Check
479
  st.title("๐Ÿค– Model Training Studio")
480
 
481
  if st.session_state.cleaned_data is not None:
@@ -646,8 +647,8 @@ elif app_mode == "Model Training": #Check
646
  except Exception as e:
647
  st.error(f"Error during training: {e}")
648
 
649
- #Predictions
650
- elif app_mode == "Predictions": #Check
651
  st.title("๐Ÿ”ฎ Make Predictions")
652
 
653
  if st.session_state.model is not None and st.session_state.preprocessor is not None:
@@ -664,7 +665,6 @@ elif app_mode == "Predictions": #Check
664
 
665
  if st.button("Predict"):
666
  try:
667
-
668
  input_df = pd.DataFrame([input_data])
669
  # Preprocess input
670
  input_processed = preprocessor.transform(input_df)
@@ -684,8 +684,9 @@ elif app_mode == "Predictions": #Check
684
  st.error(f"Error during prediction: {e}")
685
  else:
686
  st.warning("Please train a model first.")
687
-
688
- elif app_mode == "Visualization Lab":
 
689
  st.title("๐Ÿ“Š Advanced Visualization Lab")
690
 
691
  if st.session_state.cleaned_data is not None:
 
159
  h1, h2, h3, h4, h5, h6 {
160
  color: #00f7ff !important; /* Headings to cyan */
161
  }
162
+
163
  /* Styles for loader */
164
  .loader {
165
  border: 5px solid #f3f3f3;
 
169
  height: 30px;
170
  animation: spin 2s linear infinite;
171
  }
172
+
173
  @keyframes spin {
174
  0% { transform: rotate(0deg); }
175
  100% { transform: rotate(360deg); }
 
182
  # --- Image Loading ---
183
  @st.cache_data(ttl=3600)
184
  async def load_image(image_url):
185
+ """Loads an image from a URL asynchronously and returns bytes."""
186
  try:
187
  response = requests.get(image_url, stream=True)
188
  response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
189
+ return response.content # Return image data as bytes
190
  except requests.exceptions.RequestException as e:
191
  st.error(f"Error loading image: {e}")
192
+ return None
193
 
194
  async def set_background():
195
  """Sets the background image."""
196
+ image_url = "https://images.unsplash.com/photo-1504821618514-8c1b6e408ca8?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1949&q=80"
197
  image_data = await load_image(image_url)
198
 
199
  if image_data:
 
201
  f"""
202
  <style>
203
  .stApp {{
204
+ background-image: url(data:image/{"jpeg"};base64,{image_data.hex()});
205
  background-size: cover;
206
  }}
207
  </style>
 
279
  time.sleep(0.01) # reduced sleep timer as its getting too long
280
 
281
  # --- Main App Logic ---
282
+ if app_mode == "Data Upload":
 
283
  st.title("๐Ÿ“ค Data Upload & Analysis")
284
 
285
  uploaded_file = st.file_uploader("Upload Dataset", type=["csv", "xlsx"])
 
305
  pr = generate_profile(df)
306
  st_profile_report(pr)
307
 
308
+ elif app_mode == "Smart Cleaning":
309
  st.title("๐Ÿงผ Intelligent Data Cleaning")
310
 
311
  if st.session_state.raw_data is not None:
 
414
  with col2:
415
  st.write("Cleaned Data", df.head(3))
416
 
417
+ elif app_mode == "Advanced EDA":
418
  st.title("๐Ÿ” Advanced Exploratory Analysis")
419
 
420
  if st.session_state.cleaned_data is not None:
 
476
  except Exception as e:
477
  st.error(f"Error generating plot: {e}")
478
 
479
+ elif app_mode == "Model Training":
480
  st.title("๐Ÿค– Model Training Studio")
481
 
482
  if st.session_state.cleaned_data is not None:
 
647
  except Exception as e:
648
  st.error(f"Error during training: {e}")
649
 
650
+ # Predictions Section
651
+ elif app_mode == "Predictions":
652
  st.title("๐Ÿ”ฎ Make Predictions")
653
 
654
  if st.session_state.model is not None and st.session_state.preprocessor is not None:
 
665
 
666
  if st.button("Predict"):
667
  try:
 
668
  input_df = pd.DataFrame([input_data])
669
  # Preprocess input
670
  input_processed = preprocessor.transform(input_df)
 
684
  st.error(f"Error during prediction: {e}")
685
  else:
686
  st.warning("Please train a model first.")
687
+
688
+
689
+ elif app_mode == "Visualization Lab":
690
  st.title("๐Ÿ“Š Advanced Visualization Lab")
691
 
692
  if st.session_state.cleaned_data is not None: