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

Upgrade to Keras 3.0 with JAX backend and direct HF model loading

Browse files

- Set KERAS_BACKEND to 'jax' for improved performance
- Use keras.saving.load_model('hf://Siraja704/DermaAI') for direct model loading
- Remove dependency on huggingface_hub package
- Add jax[cpu] to requirements for JAX backend support
- Update README with modern technical stack information
- Simplify model loading process with new Keras 3.0 features

Files changed (3) hide show
  1. README.md +16 -1
  2. app.py +9 -12
  3. requirements.txt +2 -1
README.md CHANGED
@@ -15,10 +15,25 @@ short_description: Derma AI skin Disease model
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
 
15
 
16
  AI-powered skin condition analysis using deep learning with EfficientNetV2 architecture.
17
 
18
+ ## Features
19
+
20
+ - **Modern Keras 3.0 with JAX Backend**: Uses the latest Keras with JAX for improved performance
21
+ - **Direct HuggingFace Model Loading**: Loads models directly from HuggingFace Hub
22
+ - **5 Skin Conditions**: Classifies Atopic Dermatitis, Eczema, Psoriasis, Seborrheic Keratoses, and Tinea Ringworm Candidiasis
23
+ - **Medical Disclaimers**: Includes proper medical disclaimers and advice
24
+
25
+ ## Technical Stack
26
+
27
+ - **Backend**: JAX (via Keras 3.0)
28
+ - **Frontend**: Gradio 5.0+
29
+ - **Model Architecture**: EfficientNetV2
30
+ - **Model Source**: Direct loading from `hf://Siraja704/DermaAI`
31
+
32
  ## Setup
33
 
34
+ This application uses Keras 3.0 with JAX backend for optimal performance. The model is loaded directly from HuggingFace Hub using the new `keras.saving.load_model("hf://...")` syntax.
35
 
36
+ If the model repository is private, you may need to:
37
  1. Go to the Space settings
38
  2. Add a new secret with key `HF_TOKEN` and your Hugging Face access token as the value
39
  3. Make sure your token has access to the `Siraja704/DermaAI` model repository
app.py CHANGED
@@ -1,10 +1,13 @@
 
 
 
 
1
  import gradio as gr
2
- import tensorflow as tf
3
  import numpy as np
4
  from PIL import Image
5
- from huggingface_hub import hf_hub_download
6
  from tensorflow.keras.applications.efficientnet_v2 import preprocess_input
7
- import os
8
 
9
  # Class names for the 5 skin conditions
10
  CLASS_NAMES = [
@@ -30,17 +33,11 @@ class DermaAIModel:
30
  self.load_model()
31
 
32
  def load_model(self):
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)
 
1
+ # Available backend options are: "jax", "torch", "tensorflow".
2
+ import os
3
+ os.environ["KERAS_BACKEND"] = "jax"
4
+
5
  import gradio as gr
6
+ import keras
7
  import numpy as np
8
  from PIL import Image
9
+ import tensorflow as tf # Keep for preprocessing function
10
  from tensorflow.keras.applications.efficientnet_v2 import preprocess_input
 
11
 
12
  # Class names for the 5 skin conditions
13
  CLASS_NAMES = [
 
33
  self.load_model()
34
 
35
  def load_model(self):
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)
requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
  gradio>=5.0.0
 
 
2
  tensorflow>=2.13.0
3
- huggingface_hub>=0.20.0
4
  pillow>=9.0.0
5
  numpy>=1.21.0
 
1
  gradio>=5.0.0
2
+ keras>=3.0.0
3
+ jax[cpu]>=0.4.0
4
  tensorflow>=2.13.0
 
5
  pillow>=9.0.0
6
  numpy>=1.21.0