Spaces:
Running
Running
raymondEDS
commited on
Commit
·
73e6ea4
1
Parent(s):
1d2c7e0
week 5 file paths
Browse files- course_pages/week_5.py +25 -2
course_pages/week_5.py
CHANGED
@@ -60,8 +60,31 @@ def extract_text_features(text):
|
|
60 |
|
61 |
def load_data():
|
62 |
"""Load and prepare the data"""
|
63 |
-
#
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
# Load the datasets
|
67 |
try:
|
|
|
60 |
|
61 |
def load_data():
|
62 |
"""Load and prepare the data"""
|
63 |
+
# Try multiple possible paths for Hugging Face Spaces compatibility
|
64 |
+
import os
|
65 |
+
|
66 |
+
# Debug: Print current working directory
|
67 |
+
st.write(f"Current working directory: {os.getcwd()}")
|
68 |
+
|
69 |
+
# Try different possible data directory paths
|
70 |
+
possible_paths = [
|
71 |
+
Path("Data"), # Relative to current working directory
|
72 |
+
Path.cwd() / "Data", # Explicitly relative to current working directory
|
73 |
+
Path("/home/user/app/Data"), # Hugging Face Spaces typical path
|
74 |
+
Path("/home/user/Data"), # Alternative Hugging Face Spaces path
|
75 |
+
]
|
76 |
+
|
77 |
+
data_dir = None
|
78 |
+
for path in possible_paths:
|
79 |
+
st.write(f"Checking path: {path}")
|
80 |
+
if path.exists():
|
81 |
+
data_dir = path
|
82 |
+
st.write(f"Found data directory at: {data_dir}")
|
83 |
+
break
|
84 |
+
|
85 |
+
if data_dir is None:
|
86 |
+
st.error("Could not find Data directory in any of the expected locations")
|
87 |
+
return None, None, None, None
|
88 |
|
89 |
# Load the datasets
|
90 |
try:
|