Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- backend/database.py +5 -0
- backend/preprocessing.py +1 -1
backend/database.py
CHANGED
|
@@ -22,6 +22,11 @@ async def sync_from_hub():
|
|
| 22 |
if time.time() - last_sync < 60:
|
| 23 |
return
|
| 24 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
print(f"Downloading {settings.db_name} from Hub...")
|
| 26 |
def _download():
|
| 27 |
path = hf_hub_download(
|
|
|
|
| 22 |
if time.time() - last_sync < 60:
|
| 23 |
return
|
| 24 |
try:
|
| 25 |
+
try:
|
| 26 |
+
api.create_repo(repo_id=settings.repo_id, repo_type="dataset", exist_ok=True, token=settings.hf_token)
|
| 27 |
+
except Exception as e:
|
| 28 |
+
print(f"Failed to create repo: {e}")
|
| 29 |
+
|
| 30 |
print(f"Downloading {settings.db_name} from Hub...")
|
| 31 |
def _download():
|
| 32 |
path = hf_hub_download(
|
backend/preprocessing.py
CHANGED
|
@@ -38,7 +38,7 @@ def preprocess_data(df, is_training=True):
|
|
| 38 |
y = y_raw
|
| 39 |
|
| 40 |
# Fix broken encoding column names safely
|
| 41 |
-
X_raw.rename(columns=lambda x: x.replace('', '°') if isinstance(x, str) else x, inplace=True)
|
| 42 |
|
| 43 |
if 'Fall Detection' in X_raw.columns:
|
| 44 |
X_raw['Fall Detection'] = X_raw['Fall Detection'].map({'Yes': 1, 'No': 0}).fillna(0)
|
|
|
|
| 38 |
y = y_raw
|
| 39 |
|
| 40 |
# Fix broken encoding column names safely
|
| 41 |
+
X_raw.rename(columns=lambda x: x.replace('\ufffd', '°') if isinstance(x, str) else x, inplace=True)
|
| 42 |
|
| 43 |
if 'Fall Detection' in X_raw.columns:
|
| 44 |
X_raw['Fall Detection'] = X_raw['Fall Detection'].map({'Yes': 1, 'No': 0}).fillna(0)
|