Skip to content

Bbs1412/DistributedAttendanceSystem

Repository files navigation

Distributed Attendance System

This is the distributed processing version of the Smart Attendance System project, utilizing distributed processing for attendance calculation through face recognition.

Important

  • This README contains demonstration videos which your browser or device might not support.
  • In case the demo videos are not visible, try refreshing the page.
  • If they remain unplayable, switch to a different browser or try accessing from another device.

Index:

🎯 Project Overview:

Aim:

  • Leverage the power of multiple clients to process video frames for attendance marking using face recognition.
  • Implement both Static and Dynamic load balancing for efficient processing and faster results.

Methodology:

  1. Server Initialization:

    • A web server starts the distributed server, which connects to multiple clients (as configured in the .env file).
    • Initialization includes:
      • Accepting client connections and registering their details.
      • Sending pre-trained face models and essential files to each client.
      • Server_Initialization_H264.mp4
      • Setting clients on standby mode for task distribution.
      • Client_Initialization_H264.mp4
  2. Task Distribution:

    • The server accepts video uploads from the frontend.
    • Tasks are assigned to clients based on the selected load balancing mode:
      1. Static Load Balancing:

        • Tasks are evenly distributed before processing begins.
        • All clients must finish their tasks before results can be combined.
        • Client_Static_H264.mp4
        • Means, the server has to wait for all clients to complete the task.
        • One client has been purposely delayed to simulate the difference in processing time.
        • Server_Static_H264.mp4
      2. Dynamic Load Balancing:

        • Tasks are assigned based on client processing speed in real-time, ensuring efficient resource utilization.
        • Client_Dynamic_H264.mp4
        • All the clients finish the task approximately at the same time.
        • Server_Dynamic_H264.mp4
  3. Processing:

    • Clients process video frames using OpenCV and face_recognition.
    • Results are returned to the server.
    • Separate results from clients are combined, and rendered as attendance data.
  4. Output:

    • Results are displayed on a web page and can be downloaded in Excel format as well.

Features:

  • Web-based Interface: Upload videos and view/download attendance results.
  • Parallel Processing: Faster processing through distributed clients.
  • Customizable Load Balancing: Switch between static and dynamic modes.
  • Thread locking: For consistent read-write operations on shared resources.
  • Accurate Attendance Marking: Threshold-based attendance marking ensures precision.
  • Detailed Reporting: Faculty can access detailed results and downloadable attendance records.

Tech Stack:

  • Backend: Python, Flask
  • Frontend: HTML, CSS, JavaScript
  • Libraries: OpenCV, face_recognition, threading, socket
  • Data Formats: JSON, Excel
  • Tools: Virtual environment (venv), Python's standard libraries

πŸš€ Steps to run:

Server Setup:

  1. Clone the repository:

    git clone --depth 1 https://github.com/Bbs1412/DistributedAttendanceSystem.git
  2. Navigate to the project directory:

    cd DistributedAttendanceSystem
  3. Create a virtual environment and install dependencies:

    python -m venv venv
    venv\Scripts\activate
    pip install -r "requirements_all.txt"
  4. Configure the number of clients in the .env file:

    no_of_clients = 2
  5. Train the face recognition models:

    • Create a folder named Pics in the project directory and add the images of the people you want to recognize in the Pics folder.
    • Update the people list in face_train.py (~line 73)::
      Person(
          reg='registration_number',
          name='Name',
          image='person_name.jpg',      # Image should be in the 'Pics' folder
          display_name='Display Name',  # optional
          pickle_name='person_name.pkl' # optional
      )
    • Run the training script:
      python face_train.py
  6. Start the web server:

    python app.py
  7. Connect clients:

    • Run the distributed_client.py on all the clients within span of set timeout.
  8. Open the browser at:

    http://localhost:5000
    

Client Setup:

  1. Clone the repository:

    git clone --depth 1 https://github.com/Bbs1412/DistributedAttendanceSystem.git
  2. Copy networking.py and logger.py from the root directory to Client/ directory.

  3. Navigate to the client directory:

    cd DistributedAttendanceSystem/Client
  4. Create a virtual environment and install dependencies:

    python -m venv venv
    venv\Scripts\activate
    cp ../requirements_all.txt .
    pip install -r "requirements_all.txt"
  5. Rest all files outside Client/ can be deleted.

  6. Run the client once main server is up:

    python distributed_client.py
  7. Repeat the above steps for all the clients.


πŸ“ Extras:

  • Networking module:

    • The networking.py module provides abstraction for client-server communication.
    • It uses a structured JSON based custom protocol, which can be checked in Protocol.json file.
    • Includes functions for sending and receiving data over sockets.
    • Robust error handling and logging are implemented for better debugging.
    • Sender-side: Retries sending the same message up to 3 times if an error occurs (can be adjusted in the networking.py file).
    • Receiver-side: Sends NACK (negative acknowledgment) to the sender if an error is detected, prompting the sender to resend the data.
    • Data sent in parts over the network is reassembled at the receiver's end.
  • Logger module:

    • The logger.py module is also implemented using the same protocol.
    • It provides logging functionality for efficient debugging and status tracking of the distributed system.
    • Can be disabled in high performance scenarios, as it may impact the performance due to frequent I/O operations.

🀝 Contributions:

Any contributions or suggestions are welcome!

πŸ“œ License:

Code-License

  • This project is licensed under the GNU General Public License v3.0
  • See the LICENSE file for details.
  • You can use the code with proper credits to the author.

πŸ“§ Contact:


About

This is the distributed processing version of the 'Smart Attendance System' project.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published