Spaces:
Sleeping
Sleeping
Deploy Polyglot backend with quantized models
Browse files- deploy_with_env.py +27 -0
- requirements.txt +3 -0
deploy_with_env.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Deploy Docker space with .env token loading"""
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
from dotenv import load_dotenv
|
| 7 |
+
|
| 8 |
+
# Load .env file
|
| 9 |
+
env_file = Path("C:/repos/longonot/local/.env")
|
| 10 |
+
if env_file.exists():
|
| 11 |
+
load_dotenv(env_file)
|
| 12 |
+
|
| 13 |
+
# Get token
|
| 14 |
+
hf_token = os.getenv('HF_TOKEN') or os.getenv('HUGGING_FACE_HUB_TOKEN')
|
| 15 |
+
if not hf_token:
|
| 16 |
+
print("[ERROR] No HuggingFace token found in .env!")
|
| 17 |
+
sys.exit(1)
|
| 18 |
+
|
| 19 |
+
# Set environment variable
|
| 20 |
+
os.environ['HUGGING_FACE_HUB_TOKEN'] = hf_token
|
| 21 |
+
|
| 22 |
+
# Now import and run the deployment
|
| 23 |
+
sys.path.insert(0, str(Path(__file__).parent))
|
| 24 |
+
from deploy_to_hf import deploy_to_huggingface
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
deploy_to_huggingface()
|
requirements.txt
CHANGED
|
@@ -34,6 +34,9 @@ numpy==2.1.3
|
|
| 34 |
nltk==3.9.1
|
| 35 |
sentencepiece==0.2.0
|
| 36 |
|
|
|
|
|
|
|
|
|
|
| 37 |
# Computer vision and image processing
|
| 38 |
pillow==11.0.0
|
| 39 |
qrcode[pil]==8.0
|
|
|
|
| 34 |
nltk==3.9.1
|
| 35 |
sentencepiece==0.2.0
|
| 36 |
|
| 37 |
+
# CTranslate2 for optimized translation inference
|
| 38 |
+
ctranslate2>=4.6.0
|
| 39 |
+
|
| 40 |
# Computer vision and image processing
|
| 41 |
pillow==11.0.0
|
| 42 |
qrcode[pil]==8.0
|