Spaces:
Running
Running
Update src/ai_processor.py
Browse files- src/ai_processor.py +15 -3
src/ai_processor.py
CHANGED
|
@@ -16,9 +16,21 @@ import cv2
|
|
| 16 |
import numpy as np
|
| 17 |
from PIL import Image
|
| 18 |
from PIL.ExifTags import TAGS
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# --- Logging config ---
|
| 24 |
logging.basicConfig(
|
|
|
|
| 16 |
import numpy as np
|
| 17 |
from PIL import Image
|
| 18 |
from PIL.ExifTags import TAGS
|
| 19 |
+
import os, logging
|
| 20 |
+
from huggingface_hub import HfFolder
|
| 21 |
+
|
| 22 |
+
# Read from env (prefer standard uppercase)
|
| 23 |
+
HF_TOKEN = os.getenv("HF_TOKEN") or os.getenv("hf_token")
|
| 24 |
+
|
| 25 |
+
if HF_TOKEN:
|
| 26 |
+
# Persist for the ubuntu user so HF/Transformers can reuse it
|
| 27 |
+
HfFolder.save_token(HF_TOKEN)
|
| 28 |
+
# Also keep it in-process for libraries that accept a token kwarg
|
| 29 |
+
os.environ["HF_TOKEN"] = HF_TOKEN
|
| 30 |
+
logging.info("✅ Hugging Face token configured without interactive login.")
|
| 31 |
+
else:
|
| 32 |
+
logging.warning("⚠️ HF_TOKEN not set. Set it in /etc/default/smartheal for private/gated models.")
|
| 33 |
+
|
| 34 |
|
| 35 |
# --- Logging config ---
|
| 36 |
logging.basicConfig(
|