Spaces:
Sleeping
Sleeping
Daniel kiani
commited on
update path
Browse files- scripts/app.py +8 -4
scripts/app.py
CHANGED
|
@@ -32,8 +32,10 @@ def load_artifacts():
|
|
| 32 |
|
| 33 |
# Configuration
|
| 34 |
CHECKPOINT_PATH = "checkpoints/sasrec-epoch=06-val_hitrate@10=0.3629.ckpt"
|
| 35 |
-
DATA_FOLDER = "data/"
|
| 36 |
DATA_REPO_ID = "Deathshot78/RetailRocket-Recommender-Data"
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# --- Download Data from Hugging Face Hub ---
|
| 39 |
print(f"Downloading data from Hugging Face Hub repo: {DATA_REPO_ID}")
|
|
@@ -47,9 +49,9 @@ def load_artifacts():
|
|
| 47 |
for filename in files_to_download:
|
| 48 |
hf_hub_download(
|
| 49 |
repo_id=DATA_REPO_ID,
|
| 50 |
-
#
|
| 51 |
filename=f"data/RetailRocket-Recommender-Data/data/{filename}",
|
| 52 |
-
local_dir=".", # Download to the root of the Space
|
| 53 |
repo_type="dataset"
|
| 54 |
)
|
| 55 |
print("All data files downloaded successfully.")
|
|
@@ -64,12 +66,14 @@ def load_artifacts():
|
|
| 64 |
MODEL.eval()
|
| 65 |
|
| 66 |
print("Preparing data from downloaded files...")
|
|
|
|
| 67 |
train_set, validation_set, test_set = prepare_data(data_folder=DATA_FOLDER)
|
| 68 |
|
| 69 |
DATAMODULE = SASRecDataModule(train_set, validation_set, test_set)
|
| 70 |
DATAMODULE.setup()
|
| 71 |
|
| 72 |
print("Loading item and category maps...")
|
|
|
|
| 73 |
ITEM_CATEGORY_MAP = load_item_properties(data_folder=DATA_FOLDER)
|
| 74 |
CATEGORY_PARENT_MAP = load_category_tree(data_folder=DATA_FOLDER)
|
| 75 |
|
|
@@ -184,4 +188,4 @@ if __name__ == "__main__":
|
|
| 184 |
|
| 185 |
# For local testing, this creates a shareable link.
|
| 186 |
# On Hugging Face Spaces, this is not strictly necessary but doesn't hurt.
|
| 187 |
-
iface.launch(share=True)
|
|
|
|
| 32 |
|
| 33 |
# Configuration
|
| 34 |
CHECKPOINT_PATH = "checkpoints/sasrec-epoch=06-val_hitrate@10=0.3629.ckpt"
|
|
|
|
| 35 |
DATA_REPO_ID = "Deathshot78/RetailRocket-Recommender-Data"
|
| 36 |
+
# FIX: Define the correct, full path to where the data will be after download.
|
| 37 |
+
# The nested structure comes from the path within the HF Hub dataset repo.
|
| 38 |
+
DATA_FOLDER = "data/RetailRocket-Recommender-Data/data"
|
| 39 |
|
| 40 |
# --- Download Data from Hugging Face Hub ---
|
| 41 |
print(f"Downloading data from Hugging Face Hub repo: {DATA_REPO_ID}")
|
|
|
|
| 49 |
for filename in files_to_download:
|
| 50 |
hf_hub_download(
|
| 51 |
repo_id=DATA_REPO_ID,
|
| 52 |
+
# The path to the file within the dataset repo
|
| 53 |
filename=f"data/RetailRocket-Recommender-Data/data/{filename}",
|
| 54 |
+
local_dir=".", # Download to the root of the Space, preserving structure
|
| 55 |
repo_type="dataset"
|
| 56 |
)
|
| 57 |
print("All data files downloaded successfully.")
|
|
|
|
| 66 |
MODEL.eval()
|
| 67 |
|
| 68 |
print("Preparing data from downloaded files...")
|
| 69 |
+
# Use the corrected DATA_FOLDER path
|
| 70 |
train_set, validation_set, test_set = prepare_data(data_folder=DATA_FOLDER)
|
| 71 |
|
| 72 |
DATAMODULE = SASRecDataModule(train_set, validation_set, test_set)
|
| 73 |
DATAMODULE.setup()
|
| 74 |
|
| 75 |
print("Loading item and category maps...")
|
| 76 |
+
# Use the corrected DATA_FOLDER path
|
| 77 |
ITEM_CATEGORY_MAP = load_item_properties(data_folder=DATA_FOLDER)
|
| 78 |
CATEGORY_PARENT_MAP = load_category_tree(data_folder=DATA_FOLDER)
|
| 79 |
|
|
|
|
| 188 |
|
| 189 |
# For local testing, this creates a shareable link.
|
| 190 |
# On Hugging Face Spaces, this is not strictly necessary but doesn't hurt.
|
| 191 |
+
iface.launch(share=True)
|