CoolFace
Apppublic

lbl/redaction

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes
setup_models.py22 linesDownload Raw Back to api
1import spacy2import os3import subprocess4import sys5 6MODELS = ["en_core_web_lg", "fr_core_news_lg"]7 8def check_and_download():9    for model in MODELS:10        try:11            print(f"๐Ÿ” Checking if {model} is installed...")12            spacy.load(model)13            print(f"โœ… {model} is already present.")14        except OSError:15            print(f"๐Ÿ“ฅ {model} not found. Downloading (this may take a few minutes)...")16            # Using --user to ensure it goes into a writable directory for non-root users17            subprocess.check_call([sys.executable, "-m", "spacy", "download", model, "--user"])18            print(f"โœจ {model} downloaded successfully.")19 20if __name__ == "__main__":21    check_and_download()22