fedscale.edge.execution¶
This directory contains minimum files modified from MNN Android Demo. The training and testing will be conducted by MNN C++ backend, while the task execution and communication with server will be managed by Java. The sample has been tested upon image classification with a simple linear model and a small subset of ImageNet-MINI. This documentation contains a step-by-step tutorial on how to download, build and config this app on your own device, and modify this app for your own implementation and deployment.
Download and build sample android app¶
Download and unzip sample dataset (TrainTest.zip) to
assets/
directory. RemoveTrainTest.zip
after unzip to save space on your mobile device. After unzip, you should see 3 files and 2 directories underassets/
:TrainSet
: Training set directory, contains 316 images.TestSet
: Testing set directory, contains 34 images.conf.json
: Configuration file for mobile app.train_labels.txt
: Training label file with format<filename> <label>
, where<filename>
is the path afterTrainSet/
.test_labels.txt
: Testing label file with the same format astrain_labels.txt
.
Run
sh install.sh
. If you are on Windows, please run this command in WSL. This step will clone MNN, replace MNN Android Demo with FedScale Android Executor underMNN/project/android/demo
. Note: you may want to move MNN directory to another directory, otherwise the full file path might be too long for cmake to build.Install Android Studio and open project
MNN/project/android/demo
. Download necessary SDKs, NDKs and CMake when prompted. My version:SDK: API 28
NDK: 20.0.5594570
Android Gradle Plugin Version: 3.5.3
Gradle Version: 5.4.1
Source Compatibility: Java 8
Target Compatibility: Java 8
Make project. Android Studio will compile and build the app for you.
Test this app with default setting¶
ssh to your own server and run
cd fedscale/cloud/aggregation/android
python3 android_aggregator.py --experiment_mode=mobile --num_participants=1 --model=linear
Change aggregator IP address inside
assets/conf.json
and clickRun
inside Android Studio.
Customize your own app¶
If you want to use your own dataset, please put your data under
assets/TrainSet
andassets/TestSet
, make sure that your label has the same format as my label file.If you want to change the file/dir name under
assets
, please make sure to change the corresponding config inassets
attribute insideassets/conf.json
.
If you want to use your own model for image classification, please either change
channel
,width
andheight
insideassets/conf.json
to your own input and changenum_classes
to your own classes, or override these attributes when sendingCLIENT_TRAIN
request.If you want to use your own model for tasks other than image classification, you may need to write your own JNI C++ trainer and tester. Please refer to MNN for further development guide. You may also need to change
channel
,width
andheight
insideassets/conf.json
to your own input and change or removenum_classes
.Please note that MNN does not support DropOut and will SegFault during training. MNN may have other potential bugs.