Siddhartha276/Fall_Detection
015
1---2license: mit3language:4- en5base_model:6- google/efficientnet-b07---8 9# Fall Detection Model using EfficientNetB010 11This 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**.12 13---14 15## Model Architecture16 17- **Base Model**: EfficientNetB0 (`include_top=False`, pretrained on ImageNet)18- **Top Layers**:19 - GlobalAveragePooling2D20 - BatchNormalization21 - Dropout (0.4)22 - Dense (sigmoid activation)23- **Loss Function**: Binary Crossentropy24- **Optimizer**: Adam25 26The model was trained in two phases:27- Initial training with base model frozen (10 epochs)28- Fine-tuning with selective unfreezing (5 additional epochs)29 30Data augmentation techniques like `RandomFlip`, `RandomRotation`, and `RandomZoom` are used during training.31 32---33 34The repository contains **two versions of the model**:35 361. **Keras `.h5` model** 37 - Full model for general use on machines with standard computational capacity.382. **TensorFlow Lite `.tflite` model** 39 - Optimized for mobile and edge devices with limited computing power.40 41---42 43## How to Use44 45### 1. Load the Model from Hugging Face46 47```python48from huggingface_hub import from_pretrained_keras49 50# Replace with your actual repo path51model = from_pretrained_keras("author-username/model-name")52```53 54### 2. Run Inference on an Image55 56```python57from tensorflow.keras.preprocessing import image58from tensorflow.keras.applications.efficientnet import preprocess_input59import numpy as np60import matplotlib.pyplot as plt61 62# Define image size63IMG_SIZE = (224, 224)64 65# Load and preprocess the image66img_path = "image_uri" # Your image uri (from the drive or local storage)67img = image.load_img(img_path, target_size=IMG_SIZE)68img_array = image.img_to_array(img)69img_array = np.expand_dims(img_array, axis=0)70img_array = preprocess_input(img_array)71 72# Display the image73plt.imshow(img)74plt.axis("off")75plt.show()76 77# Make prediction78prediction = model.predict(img_array)79print(prediction)80 81# Interpret prediction82if prediction[0] < 0.15:83 print("Prediction: ๐จ Fall Detected! ๐จ")84else:85 print("Prediction: โ
No Fall Detected.")86```87 88 