Spaces:
Sleeping
Sleeping
Download utils.py from mustafa2ak/building_detection: direct link, hf CLI and curl.
- Browser
- Download file 888 Bytes
-
https://huggingface.co/spaces/mustafa2ak/building_detection/resolve/main/utils.py
- Command line
-
hf download hf://spaces/mustafa2ak/building_detection/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/mustafa2ak/building_detection/resolve/main/utils.py
888 Bytes
| import os | |
| import zipfile | |
| import shutil | |
| def setup_dataset(zip_path="test.zip", extract_path="./dataset"): | |
| """Extract dataset if not already extracted""" | |
| dataset_path = os.path.join(extract_path, "test") | |
| if not os.path.exists(dataset_path): | |
| print("Extracting dataset...") | |
| os.makedirs(extract_path, exist_ok=True) | |
| try: | |
| with zipfile.ZipFile(zip_path, 'r') as zip_ref: | |
| zip_ref.extractall(extract_path) | |
| print("Dataset extracted successfully!") | |
| except Exception as e: | |
| print(f"Error extracting dataset: {e}") | |
| return None | |
| return dataset_path | |
| def cleanup_cache(): | |
| """Clean up any temporary files""" | |
| cache_dirs = ['__pycache__', '.ipynb_checkpoints'] | |
| for cache_dir in cache_dirs: | |
| if os.path.exists(cache_dir): | |
| shutil.rmtree(cache_dir) |