Siraja704 commited on
Commit
4835d52
Β·
1 Parent(s): a20be1c

Add authentication support for private model access

Browse files

- Add HF_TOKEN support for accessing gated/private model repository
- Update README.md with setup instructions for authentication
- Add detailed error handling for authentication issues
- Provide clear instructions for adding HF_TOKEN to Space secrets

Files changed (2) hide show
  1. README.md +20 -0
  2. app.py +12 -1
README.md CHANGED
@@ -11,4 +11,24 @@ license: mit
11
  short_description: Derma AI skin Disease model
12
  ---
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
11
  short_description: Derma AI skin Disease model
12
  ---
13
 
14
+ # DermaAI - Skin Disease Classification
15
+
16
+ AI-powered skin condition analysis using deep learning with EfficientNetV2 architecture.
17
+
18
+ ## Setup
19
+
20
+ This Space requires authentication to access the private model. To run this Space:
21
+
22
+ 1. Go to the Space settings
23
+ 2. Add a new secret with key `HF_TOKEN` and your Hugging Face access token as the value
24
+ 3. Make sure your token has access to the `Siraja704/DermaAI` model repository
25
+
26
+ ## Supported Conditions
27
+
28
+ - Atopic Dermatitis
29
+ - Eczema
30
+ - Psoriasis
31
+ - Seborrheic Keratoses
32
+ - Tinea Ringworm Candidiasis
33
+
34
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -33,14 +33,25 @@ class DermaAIModel:
33
  """Load the DermaAI model from Hugging Face Hub"""
34
  try:
35
  print("πŸ”„ Loading DermaAI model from Hugging Face...")
 
 
36
  model_path = hf_hub_download(
37
  repo_id="Siraja704/DermaAI",
38
- filename="DermaAI.keras"
 
39
  )
40
  self.model = tf.keras.models.load_model(model_path)
41
  print("βœ… Model loaded successfully!")
42
  except Exception as e:
 
43
  print(f"❌ Error loading model: {e}")
 
 
 
 
 
 
 
44
  raise e
45
 
46
  def predict(self, image):
 
33
  """Load the DermaAI model from Hugging Face Hub"""
34
  try:
35
  print("πŸ”„ Loading DermaAI model from Hugging Face...")
36
+ # Get HF token from environment variable for authentication
37
+ hf_token = os.getenv("HF_TOKEN")
38
  model_path = hf_hub_download(
39
  repo_id="Siraja704/DermaAI",
40
+ filename="DermaAI.keras",
41
+ token=hf_token
42
  )
43
  self.model = tf.keras.models.load_model(model_path)
44
  print("βœ… Model loaded successfully!")
45
  except Exception as e:
46
+ error_msg = str(e)
47
  print(f"❌ Error loading model: {e}")
48
+ if "401" in error_msg or "gated" in error_msg.lower() or "restricted" in error_msg.lower():
49
+ print("\nπŸ” AUTHENTICATION ERROR:")
50
+ print("- The model repository is private/gated")
51
+ print("- Please add your HF_TOKEN to the Space secrets")
52
+ print("- Go to Space Settings > Repository secrets")
53
+ print("- Add: HF_TOKEN = your_huggingface_token")
54
+ print("- Make sure the token has access to Siraja704/DermaAI\n")
55
  raise e
56
 
57
  def predict(self, image):