--- license: mit language: - en base_model: - google/efficientnet-b0 --- # Fall Detection Model using EfficientNetB0 This model detects whether a person has **fallen** in an input image using transfer learning with **EfficientNetB0**. It is trained for binary classification: **Fall Detected** or **No Fall Detected**. --- ## Model Architecture - **Base Model**: EfficientNetB0 (`include_top=False`, pretrained on ImageNet) - **Top Layers**: - GlobalAveragePooling2D - BatchNormalization - Dropout (0.4) - Dense (sigmoid activation) - **Loss Function**: Binary Crossentropy - **Optimizer**: Adam The model was trained in two phases: - Initial training with base model frozen (10 epochs) - Fine-tuning with selective unfreezing (5 additional epochs) Data augmentation techniques like `RandomFlip`, `RandomRotation`, and `RandomZoom` are used during training. --- The repository contains **two versions of the model**: 1. **Keras `.h5` model** - Full model for general use on machines with standard computational capacity. 2. **TensorFlow Lite `.tflite` model** - Optimized for mobile and edge devices with limited computing power. --- ## How to Use ### 1. Load the Model from Hugging Face ```python from huggingface_hub import from_pretrained_keras # Replace with your actual repo path model = from_pretrained_keras("author-username/model-name") ``` ### 2. Run Inference on an Image ```python from tensorflow.keras.preprocessing import image from tensorflow.keras.applications.efficientnet import preprocess_input import numpy as np import matplotlib.pyplot as plt # Define image size IMG_SIZE = (224, 224) # Load and preprocess the image img_path = "image_uri" # Your image uri (from the drive or local storage) img = image.load_img(img_path, target_size=IMG_SIZE) img_array = image.img_to_array(img) img_array = np.expand_dims(img_array, axis=0) img_array = preprocess_input(img_array) # Display the image plt.imshow(img) plt.axis("off") plt.show() # Make prediction prediction = model.predict(img_array) print(prediction) # Interpret prediction if prediction[0] < 0.15: print("Prediction: 🚨 Fall Detected! 🚨") else: print("Prediction: ✅ No Fall Detected.") ```