tahirsher commited on
Commit
551152e
·
verified ·
1 Parent(s): 51b1774

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -16,8 +16,15 @@ from transformers import (
16
  # ================================
17
  # 1️⃣ Authenticate with Hugging Face Hub
18
  # ================================
19
- HF_TOKEN = "hf_token" # Replace with your Hugging Face token
20
- login(token=HF_TOKEN) # Ensure authentication
 
 
 
 
 
 
 
21
 
22
  # ================================
23
  # 2️⃣ Load Model & Processor
 
16
  # ================================
17
  # 1️⃣ Authenticate with Hugging Face Hub
18
  # ================================
19
+
20
+ # Get HF token securely from environment variables
21
+ HF_TOKEN = os.getenv("HF_TOKEN")
22
+
23
+ if HF_TOKEN is None:
24
+ raise ValueError("❌ Hugging Face API token not found. Please set it in Secrets.")
25
+
26
+ # Login using the stored token
27
+ login(token=HF_TOKEN)
28
 
29
  # ================================
30
  # 2️⃣ Load Model & Processor