Spaces:
Paused
Deployment Paths Configuration
Overview
This document explains how paths work for both local testing and Hugging Face Spaces deployment.
Directory Structure
Local Structure
huggingface/
βββ models/ # Sibling to spad_for_vision_space
β βββ spatiotemporal/
β βββ material_detection_head/
β βββ ...
βββ datasets/ # Sibling to spad_for_vision_space
β βββ testmages_spatiotemporal/
β βββ ...
βββ spad_for_vision_space/
βββ app.py # BASE_DIR
Hugging Face Spaces Structure
/app/ # BASE_DIR (Space root)
βββ models/ # Downloaded from Hub
β βββ spatiotemporal/
β βββ ...
βββ datasets/ # Downloaded from Hub
β βββ testmages_spatiotemporal/
β βββ ...
βββ app.py
Path Resolution
Base Directory
- BASE_DIR: Always resolves to the directory containing
app.py - Local:
/Users/pd3rvr/Documents/pubs/THESIS/thetex/huggingface/spad_for_vision_space - Hugging Face Spaces:
/app(or wherever the Space runs from)
Models Paths
The app uses get_models_dir() helper function to determine the correct path:
Local Testing:
- Models are siblings to
spad_for_vision_space:../models/<model_type>/ - Example:
/Users/pd3rvr/Documents/pubs/THESIS/thetex/huggingface/models/spatiotemporal/training_results_material_classifier_best_99.25%.pth
Hugging Face Spaces:
- Models are downloaded from
mvplus/spatiotemporal_modelsto:BASE_DIR/models/ - The download preserves folder structure, so files end up in:
BASE_DIR/models/<model_type>/<file> - Example:
/app/models/spatiotemporal/training_results_material_classifier_best_99.25%.pth
Dataset Paths
The app uses get_datasets_dir() helper function to determine the correct path:
Local Testing:
- Datasets are siblings to
spad_for_vision_space:../datasets/<dataset_name>/ - Example:
/Users/pd3rvr/Documents/pubs/THESIS/thetex/huggingface/datasets/testmages_spatiotemporal/
Hugging Face Spaces:
- Datasets are downloaded from
mvplus/spatiotemporal_datasetto:BASE_DIR/datasets/ - The download preserves folder structure, so files end up in:
BASE_DIR/datasets/<dataset_name>/ - Example:
/app/datasets/testmages_spatiotemporal/
Upload Strategy
Models Upload
When uploading models to mvplus/spatiotemporal_models, preserve the folder structure:
- Upload
spatiotemporal/training_results_material_classifier_best_99.25%.pth(not just the file) - This ensures it downloads to
BASE_DIR/models/spatiotemporal/training_results_material_classifier_best_99.25%.pth
Datasets Upload
When uploading datasets to mvplus/spatiotemporal_dataset, preserve the folder structure:
- Upload
testmages_spatiotemporal/directory (with all files inside) - This ensures it downloads to
BASE_DIR/datasets/testmages_spatiotemporal/
Verification
The setup_huggingface_resources() function:
- Downloads to
BASE_DIR/models/andBASE_DIR/datasets/ - Verifies expected files exist after download
- Prints warnings if expected structure is not found
Key Points
β
Consistent Paths: All paths use BASE_DIR, which works the same locally and on Hugging Face Spaces
β Folder Structure Preserved: Uploads maintain folder structure, so downloads end up in correct locations
β Automatic Download: On Hugging Face Spaces, models/datasets download automatically on first startup
β Local Skip: Local testing skips downloads (models/datasets must be present locally)