Instructions to use Pierfrancesco/adt-str with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Pierfrancesco/adt-str with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Pierfrancesco/adt-str", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download utils/config_utils.py from Pierfrancesco/adt-str: direct link, hf CLI and curl.
- Browser
- Download file 924 Bytes
-
https://huggingface.co/Pierfrancesco/adt-str/resolve/main/utils/config_utils.py
- Command line
-
hf download hf://Pierfrancesco/adt-str/utils/config_utils.py
-
curl -L -o config_utils.py https://huggingface.co/Pierfrancesco/adt-str/resolve/main/utils/config_utils.py
924 Bytes
| import json | |
| from pathlib import Path | |
| from typing import Dict, Any | |
| from omegaconf import OmegaConf | |
| def load_config_from_yaml(config_path: str) -> Dict[str, Any]: | |
| # Return a primitive dictionary after loading to maintain backwards compatibility | |
| conf = OmegaConf.load(config_path) | |
| return OmegaConf.to_container(conf, resolve=True) | |
| def load_config(config_path: str) -> Dict[str, Any]: | |
| path = Path(config_path) | |
| if path.suffix.lower() == ".json": | |
| with path.open() as f: | |
| return json.load(f) | |
| return load_config_from_yaml(str(path)) | |
| def deep_merge_dicts(base: Dict[str, Any], override: Dict[str, Any]) -> Dict[str, Any]: | |
| # Merge using OmegaConf and return primitive dict | |
| base_conf = OmegaConf.create(base) | |
| override_conf = OmegaConf.create(override) | |
| merged_conf = OmegaConf.merge(base_conf, override_conf) | |
| return OmegaConf.to_container(merged_conf, resolve=True) | |