Spaces:
Sleeping
Sleeping
Download src/vitClassifier/utils/common.py from ALYYAN/Pneumonia-Detection-AI: direct link, hf CLI and curl.
- Browser
- Download file 860 Bytes
-
https://huggingface.co/spaces/ALYYAN/Pneumonia-Detection-AI/resolve/main/src/vitClassifier/utils/common.py
- Command line
-
hf download hf://spaces/ALYYAN/Pneumonia-Detection-AI/src/vitClassifier/utils/common.py
-
curl -L -o common.py https://huggingface.co/spaces/ALYYAN/Pneumonia-Detection-AI/resolve/main/src/vitClassifier/utils/common.py
860 Bytes
| import os | |
| import yaml | |
| import json | |
| from box import ConfigBox | |
| from box.exceptions import BoxValueError | |
| from ensure import ensure_annotations | |
| from pathlib import Path | |
| from typing import Any | |
| from vitClassifier import logger | |
| def read_yaml(path_to_yaml: Path) -> ConfigBox: | |
| try: | |
| with open(path_to_yaml) as yaml_file: | |
| content = yaml.safe_load(yaml_file) | |
| logger.info(f"yaml file: {path_to_yaml} loaded successfully") | |
| return ConfigBox(content) | |
| except BoxValueError: | |
| raise ValueError("yaml file is empty") | |
| except Exception as e: | |
| raise e | |
| def create_directories(path_to_directories: list, verbose=True): | |
| for path in path_to_directories: | |
| os.makedirs(path, exist_ok=True) | |
| if verbose: | |
| logger.info(f"created directory at: {path}") |