Spaces:
Sleeping
Sleeping
Download src/translate_init.py from SuhasGholkar/chatbot: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/spaces/SuhasGholkar/chatbot/resolve/main/src/translate_init.py
- Command line
-
hf download hf://spaces/SuhasGholkar/chatbot/src/translate_init.py
-
curl -L -o translate_init.py https://huggingface.co/spaces/SuhasGholkar/chatbot/resolve/main/src/translate_init.py
636 Bytes
| import os | |
| from huggingface_hub import snapshot_download | |
| INDIC_EN_MODEL = os.getenv("INDIC_EN_MODEL", "ai4bharat/indictrans2-indic-en-dist-200M") # hi→en | |
| INDIC_HI_MODEL = os.getenv("INDIC_HI_MODEL", "ai4bharat/indictrans2-en-indic-dist-200M") # en→hi | |
| def ensure_models_local(cache_dir: str = "/data/hf-cache") -> tuple[str, str]: | |
| os.makedirs(cache_dir, exist_ok=True) | |
| local_indic_en = snapshot_download(repo_id=INDIC_EN_MODEL, cache_dir=cache_dir, local_files_only=False) | |
| local_en_indic = snapshot_download(repo_id=INDIC_HI_MODEL, cache_dir=cache_dir, local_files_only=False) | |
| return local_indic_en, local_en_indic |