Upload entrypoint.sh with huggingface_hub
Browse files- entrypoint.sh +29 -0
entrypoint.sh
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
set -e
|
| 3 |
+
|
| 4 |
+
echo "Downloading model weights from HF Hub..."
|
| 5 |
+
python - <<'EOF'
|
| 6 |
+
from huggingface_hub import snapshot_download
|
| 7 |
+
import os, shutil
|
| 8 |
+
|
| 9 |
+
repo_id = "sheikhkmmtahmid/contract-intelligence-models"
|
| 10 |
+
token = os.environ.get("HF_TOKEN") or None
|
| 11 |
+
|
| 12 |
+
local = snapshot_download(repo_id=repo_id, repo_type="model", token=token, local_dir="/tmp/models")
|
| 13 |
+
|
| 14 |
+
def cp(src, dst):
|
| 15 |
+
os.makedirs(os.path.dirname(dst), exist_ok=True)
|
| 16 |
+
if os.path.isdir(src):
|
| 17 |
+
shutil.copytree(src, dst, dirs_exist_ok=True)
|
| 18 |
+
else:
|
| 19 |
+
shutil.copy2(src, dst)
|
| 20 |
+
|
| 21 |
+
cp(f"{local}/clause_classifier/legalbert/best", "models/clause_classifier/legalbert/best")
|
| 22 |
+
cp(f"{local}/clause_classifier/legalroberta/best", "models/clause_classifier/legalroberta/best")
|
| 23 |
+
cp(f"{local}/clause_classifier/production_config.json", "models/clause_classifier/production_config.json")
|
| 24 |
+
cp(f"{local}/anomaly_detector", "models/anomaly_detector")
|
| 25 |
+
print("Models ready.")
|
| 26 |
+
EOF
|
| 27 |
+
|
| 28 |
+
echo "Starting server..."
|
| 29 |
+
exec uvicorn api.main:app --host 0.0.0.0 --port 7860
|