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)
- README.md+16-1
- app.py+9-12
- requirements.txt+2-1
14 unmodified lines1516171819202122232414 unmodified linesAI-powered skin condition analysis using deep learning with EfficientNetV2 architecture.## SetupThis Space requires authentication to access the private model. To run this Space:1. Go to the Space settings2. Add a new secret with key `HF_TOKEN` and your Hugging Face access token as the value3. Make sure your token has access to the `Siraja704/DermaAI` model repository14 unmodified lines1516171819202122232425262728293031323334353637383914 unmodified linesAI-powered skin condition analysis using deep learning with EfficientNetV2 architecture.## Features- **Modern Keras 3.0 with JAX Backend**: Uses the latest Keras with JAX for improved performance- **Direct HuggingFace Model Loading**: Loads models directly from HuggingFace Hub- **5 Skin Conditions**: Classifies Atopic Dermatitis, Eczema, Psoriasis, Seborrheic Keratoses, and Tinea Ringworm Candidiasis- **Medical Disclaimers**: Includes proper medical disclaimers and advice## Technical Stack- **Backend**: JAX (via Keras 3.0)- **Frontend**: Gradio 5.0+- **Model Architecture**: EfficientNetV2- **Model Source**: Direct loading from `hf://Siraja704/DermaAI`## SetupThis 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.If the model repository is private, you may need to:1. Go to the Space settings2. Add a new secret with key `HF_TOKEN` and your Hugging Face access token as the value3. Make sure your token has access to the `Siraja704/DermaAI` model repository
1234567891019 unmodified lines3031323334353637383940414243444546import gradio as grimport tensorflow as tfimport numpy as npfrom PIL import Imagefrom huggingface_hub import hf_hub_downloadfrom tensorflow.keras.applications.efficientnet_v2 import preprocess_inputimport os# Class names for the 5 skin conditionsCLASS_NAMES = [19 unmodified linesself.load_model()def load_model(self):"""Load the DermaAI model from Hugging Face Hub"""try:print("🔄 Loading DermaAI model from Hugging Face...")# Get HF token from environment variable for authenticationhf_token = os.getenv("HF_TOKEN")model_path = hf_hub_download(repo_id="Siraja704/DermaAI",filename="DermaAI.keras",token=hf_token)self.model = tf.keras.models.load_model(model_path)print("✅ Model loaded successfully!")except Exception as e:error_msg = str(e)1234567891011121319 unmodified lines3334353637383940414243# Available backend options are: "jax", "torch", "tensorflow".import osos.environ["KERAS_BACKEND"] = "jax"import gradio as grimport kerasimport numpy as npfrom PIL import Imageimport tensorflow as tf # Keep for preprocessing functionfrom tensorflow.keras.applications.efficientnet_v2 import preprocess_input# Class names for the 5 skin conditionsCLASS_NAMES = [19 unmodified linesself.load_model()def load_model(self):"""Load the DermaAI model from Hugging Face Hub using Keras 3.0"""try:print("🔄 Loading DermaAI model from Hugging Face...")# Load model directly from Hugging Face using Keras 3.0self.model = keras.saving.load_model("hf://Siraja704/DermaAI")print("✅ Model loaded successfully!")except Exception as e:error_msg = str(e)
12345gradio>=5.0.0tensorflow>=2.13.0huggingface_hub>=0.20.0pillow>=9.0.0numpy>=1.21.0123456gradio>=5.0.0keras>=3.0.0jax[cpu]>=0.4.0tensorflow>=2.13.0pillow>=9.0.0numpy>=1.21.0
README.md+16-1
app.py+9-12
requirements.txt+2-1