prathamrajbhar/smart-attendance-background-validation
0
Smart Attendance - Background Validation Model
This repository contains the background validation model used in the Smart Attendance System. It is designed to verify the background context of an attendance submission to ensure the check-in occurs within a valid classroom setting, preventing spoofing attempts where users check in from home, dorm rooms, or external environments.
Model Details
- Architecture: MobileNetV1 base with classification head.
- Task: Context/Background Verification
- Input Shape:
(224, 224, 3) - Preprocessing:
- Image resized to
(224, 224). - Preprocessed using standard MobileNet preprocessing (
tensorflow.keras.applications.mobilenet.preprocess_input). - Output: Softmax/classification score representing class probabilities of the background environment.
How to Use
To load and run inference in Python:
import cv2
import numpy as np
import tensorflow as tf
from tensorflow.keras.applications.mobilenet import preprocess_input
# Load the model
model = tf.keras.models.load_model("background_mobilenet_v1.h5")
# Preprocessing
def preprocess_background(img_crop: np.ndarray) -> np.ndarray:
img_resized = cv2.resize(img_crop, (224, 224))
img_batch = np.expand_dims(img_resized, axis=0)
return preprocess_input(img_batch.astype(np.float32))
# Run inference
input_tensor = preprocess_background(image)
prediction = model.predict(input_tensor)