How ahmednull/l2cs-net works
Main Components
• Data Sources and Storage:
• Datasets: The “datasets” directory holds different datasets (e.g., MPIIFaceGaze and Gaze360) along with instructions for their preparation.
• Pre-trained Models: The “models” directory serves as the storage for the pre-trained model files (e.g., L2CSNet_gaze360.pkl).
• Core Library – l2cs Package:
• Core Modules: The “l2cs” directory contains modules that define various aspects of the system:
▪ datasets.py: Handles data loading and preprocessing tailored for gaze estimation.
▪ model.py: Defines the neural network architecture (using PyTorch), responsible for gaze prediction.
▪ pipeline.py: Orchestrates the inference pipeline by coordinating face detection, model prediction, and further processing.
▪ results.py: Manages the output from predictions, likely compiling results from model inferences.
▪ utils.py: Contains miscellaneous helper functions which might assist in data handling, metric computation, etc.
▪ vis.py: Provides functionality for visualizing the gaze tracking results, such as overlaying predictions on video frames.
• Execution and Evaluation Scripts:
• train.py: Script to initiate model training on supplied datasets with configurable hyperparameters.
• test.py: Script to run evaluations on pretrained snapshots.
• leave_one_out_eval.py: Implements leave-one-person-out evaluation, specifically for the MPIIGaze dataset.
• demo.py: A standalone demo to capture webcam input, process the frame through the Pipeline (from l2cs), and showcase gaze estimation in real time.
• External Dependencies:
• PyTorch: The backbone framework for model implementation and training.
• OpenCV (cv2): Used for video capture and image processing (notably in the demo).
Depicting Relationships and Interactions
• Data Flow:
• Data from “datasets” is fed into the modules in the l2cs package, particularly via datasets.py.
• The pipeline (in pipeline.py) takes processed input data to run it through the model (model.py) and then passes results to the visualization module (vis.py) if necessary.
• Training, testing, and evaluation scripts orchestrate these interactions, using the core modules to perform specific tasks. For example, train.py and test.py use model.py for forward passes and datasets.py for batch fetching.
• Control Flow:
• Inference Flow: demo.py and Pipeline illustrate real-time processing from webcam capture → preprocessing → model inference → rendering results.
• Evaluation Flow: Scripts such as leave_one_out_eval.py demonstrate how evaluation metrics are computed from model outputs, which are stored within designated directories (output, evaluation).
• External Interactions:
• The project integrates with external libraries (PyTorch for deep learning, OpenCV for computer vision) and encourages community contributions as seen in the README.