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

Files changed (1) hide show
  1. app.py +11 -3
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
- # Load model directly from Hugging Face using Keras 3.0
40
- self.model = keras.saving.load_model("hf://Siraja704/DermaAI")
41
- print("βœ… Model loaded successfully!")
 
 
 
 
 
 
 
 
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}")