A modular Python implementation of FairVFL adapted for the HAM10000 skin lesion dataset.
This project provides a research-ready codebase for exploring fairness and privacy in vertical federated learning using both image and tabular medical data and demonstrates metrics and plots on a modern front-end dashboard.
main.py— Entry point for training and evaluationdata.py— Data loading and preprocessing (HAM10000 images + metadata)model.py— Model architectures (CNN, tabular encoder, fairness heads)train.py— Training routinesevaluate.py— Evaluation and fairness audit routinesdashboard.py— Flask/SocketIO backend for dashboard live metricstemplates/dashboard.html— Dashboard front-end templatestatics/dashboard.css— Dashboard CSS stylesstatics/dashboard.js— Dashboard interactive JSrequirements.txt— Python dependencies.gitignore— Standard ignores for Python and data/data/— Place the HAM10000 dataset here
-
Clone this repository.
-
Download the HAM10000 dataset from here
Place the extracted folders and CSV in your/datadirectory as follows:data/ ├── HAM10000_images_part_1/ │ ├── ISIC_0024306.jpg │ ├── ... ├── HAM10000_images_part_2/ │ ├── ISIC_0032012.jpg │ ├── ... ├── HAM10000_metadata.csv -
Install dependencies:
pip install -r requirements.txt
To launch the live dashboard and start FairVFL training with real-time metrics, run:
python dashboard.pyIt opens http://localhost:5050 in your browser to view the dashboard. Dashboard front-end is served via Flask/SocketIO and will automatically update with training progress.
If you only want to run the core training and evaluation via CLI, use:
python main.pyNote: For faster testing, you can reduce the percentage of data used by setting the PERCENTAGE variable in main.py to a lower value (e.g., PERCENTAGE = 0.1 for 10% of the data). This will significantly speed up training and evaluation, making it ideal for quick experiments or debugging.**
PERCENTAGE = 0.1 # Use only 10% of data for fast testing- Comprehensive State Saving: Now saves complete training state including best metrics, round history, and model configuration
- Configuration Compatibility Check: Validates model architecture compatibility when resuming
- Usage:
python3 main.py --resumeto continue from the best saved model - State Persistence: Automatically saves training progress and can resume from any interruption
- Lightweight Image Encoder: Reduced from 5.8M to 590K parameters (90% reduction)
- Simplified CNN architecture with fewer filters
- Removed redundant dense layers
- Added stronger dropout regularization (0.3-0.5)
- Simplified Tabular Encoder: Reduced from 439K to 28K parameters (94% reduction)
- Removed complex attention mechanisms
- Streamlined architecture for 3-feature input
- Optimized Fusion Model: Reduced from 827K to 367K parameters (56% reduction)
- Stratified Sampling: Ensures minimum representation of all classes
- Log-Balanced Class Weights: New weighting strategy for extreme imbalance
- Improved Data Distribution: Guarantees at least 35 samples per class
- Better Hyperparameters: Lower learning rate (0.0005), smaller batch size (16), more epochs (5)
- Enhanced Regularization: Stronger dropout, batch normalization, early stopping
- Real Evaluation Metrics: Fixed fake placeholder metrics with actual fusion model evaluation
| Metric | Before Optimization | After Optimization |
|---|---|---|
| Image Encoder Parameters | 5,876,800 | 589,632 (-90%) |
| Tabular Encoder Parameters | 438,668 | 27,980 (-94%) |
| Fusion Model Parameters | 826,887 | 366,727 (-56%) |
| Training Time/Round | ~240s | ~75s (-69%) |
| Real Evaluation | ❌ Fake metrics | ✅ Actual fusion evaluation |
| Class Balance | Poor | ✅ Minimum 35 samples/class |
| Resume Capability | ❌ Basic | ✅ Full state restoration |
- Validation Accuracy: Improved from 6% to 22% (3.7x improvement)
- Model Efficiency: Dramatically reduced overfitting risk
- Training Stability: Better convergence with improved regularization
- Real Metrics: Now shows actual model performance instead of fake placeholders
- Data Augmentation: Implement advanced image augmentation strategies
- Transfer Learning: Use pre-trained models for better feature extraction
- Advanced Fusion: Implement cross-attention mechanisms
- Ensemble Methods: Combine multiple model predictions
- Hyperparameter Tuning: Systematic optimization of learning parameters