Spaces:
Sleeping
Sleeping
Download setup.py from Shruthi1215/guvi-document-api: direct link, hf CLI and curl.
- Browser
- Download file 1.74 kB
-
https://huggingface.co/spaces/Shruthi1215/guvi-document-api/resolve/main/setup.py
- Command line
-
hf download hf://spaces/Shruthi1215/guvi-document-api/setup.py
-
curl -L -o setup.py https://huggingface.co/spaces/Shruthi1215/guvi-document-api/resolve/main/setup.py
1.74 kB
| """ | |
| Setup script for spaCy model download and TextBlob corpus. | |
| Run once after installing requirements.txt | |
| """ | |
| import subprocess | |
| import sys | |
| def run(cmd): | |
| print(f"Running: {' '.join(cmd)}") | |
| result = subprocess.run(cmd, capture_output=False) | |
| if result.returncode != 0: | |
| print(f"Warning: command returned non-zero exit code {result.returncode}") | |
| if __name__ == "__main__": | |
| print("=" * 50) | |
| print("Setting up Intelligent Document Processing API") | |
| print("=" * 50) | |
| # Download the best available spaCy model | |
| print("\n[1/3] Downloading spaCy NER model (en_core_web_lg)...") | |
| run([sys.executable, "-m", "spacy", "download", "en_core_web_lg"]) | |
| # Also grab transformer model as optional upgrade | |
| print("\n[2/3] Downloading TextBlob corpora...") | |
| run([sys.executable, "-c", "import textblob; textblob.download_corpora()"]) | |
| print("\n[3/3] Verifying installations...") | |
| try: | |
| import spacy | |
| nlp = spacy.load("en_core_web_lg") | |
| print(f" β spaCy model loaded: {nlp.meta['name']}") | |
| except Exception as e: | |
| print(f" β spaCy model issue: {e}") | |
| try: | |
| from transformers import pipeline | |
| print(" β Transformers available") | |
| except Exception as e: | |
| print(f" β Transformers issue: {e}") | |
| try: | |
| import pytesseract | |
| version = pytesseract.get_tesseract_version() | |
| print(f" β Tesseract available: version {version}") | |
| except Exception as e: | |
| print(f" β Tesseract not found: {e}") | |
| print(" β Install Tesseract: https://github.com/UB-Mannheim/tesseract/wiki") | |
| print("\nSetup complete! Start the API with:") | |
| print(" uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload") | |