NaveenKumar5 commited on
Commit
349ac02
·
verified ·
1 Parent(s): f7daa77

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +4 -1
src/streamlit_app.py CHANGED
@@ -9,8 +9,11 @@ import torch
9
  from transformers import DetrImageProcessor, DetrForObjectDetection
10
  from huggingface_hub import login
11
 
12
- # Get token from environment (set as secret in HF Spaces)
13
  HUGGINGFACE_TOKEN = os.environ.get("HF_TOKEN")
 
 
 
14
  login(token=HUGGINGFACE_TOKEN)
15
 
16
  # === Load Model and Processor ===
 
9
  from transformers import DetrImageProcessor, DetrForObjectDetection
10
  from huggingface_hub import login
11
 
12
+ # Secure token handling
13
  HUGGINGFACE_TOKEN = os.environ.get("HF_TOKEN")
14
+ if HUGGINGFACE_TOKEN is None:
15
+ raise ValueError("Hugging Face token not found in environment. Please set HF_TOKEN in Space secrets.")
16
+
17
  login(token=HUGGINGFACE_TOKEN)
18
 
19
  # === Load Model and Processor ===