Siraja704
commited on
Commit
Β·
0da07af
1
Parent(s):
c67397a
Security: Remove hardcoded HF token, use environment variable only
Browse files- Remove hardcoded token from code for security
- Token now only sourced from HF_TOKEN environment variable
- Maintains proper authentication while keeping token private
- Updated error handling to guide users on token setup
app.py
CHANGED
|
@@ -36,9 +36,17 @@ class DermaAIModel:
|
|
| 36 |
"""Load the DermaAI model from Hugging Face Hub using Keras 3.0"""
|
| 37 |
try:
|
| 38 |
print("π Loading DermaAI model from Hugging Face...")
|
| 39 |
-
#
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
except Exception as e:
|
| 43 |
error_msg = str(e)
|
| 44 |
print(f"β Error loading model: {e}")
|
|
|
|
| 36 |
"""Load the DermaAI model from Hugging Face Hub using Keras 3.0"""
|
| 37 |
try:
|
| 38 |
print("π Loading DermaAI model from Hugging Face...")
|
| 39 |
+
# Get authentication token from environment variable only (secure)
|
| 40 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 41 |
+
|
| 42 |
+
if hf_token:
|
| 43 |
+
# Load model with authentication
|
| 44 |
+
self.model = keras.saving.load_model("hf://Siraja704/DermaAI", token=hf_token)
|
| 45 |
+
print("β
Model loaded successfully with authentication!")
|
| 46 |
+
else:
|
| 47 |
+
# Try loading without token (if model becomes public)
|
| 48 |
+
self.model = keras.saving.load_model("hf://Siraja704/DermaAI")
|
| 49 |
+
print("β
Model loaded successfully!")
|
| 50 |
except Exception as e:
|
| 51 |
error_msg = str(e)
|
| 52 |
print(f"β Error loading model: {e}")
|