Skip to content

Commit 2488b3f

Browse files
XinYao1994jaypume
authored andcommitted
add federated learning inplementation by plato
Signed-off-by: XinYao1994 <[email protected]>
1 parent d920f8e commit 2488b3f

File tree

19 files changed

+427
-151
lines changed

19 files changed

+427
-151
lines changed

build/crd-samples/sedna/federatedlearningjob_yolo_v1alpha1.yaml

+37-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
spec:
66
pretrainedModel: # option
77
name: "yolo-v5-pretrained-model"
8-
transimitter: # option
8+
transmitter: # option
99
ws: { } # option, by default
1010
s3: # option, but at least one
1111
aggDataPath: "s3://sedna/fl/aggregation_data"
@@ -17,7 +17,7 @@ spec:
1717
spec:
1818
nodeName: "sedna-control-plane"
1919
containers:
20-
- image: kubeedge/sedna-fl-aggregation:mistnetyolo
20+
- image: kubeedge/sedna-example-federated-learning-mistnet-yolo-aggregator:v0.4.0
2121
name: agg-worker
2222
imagePullPolicy: IfNotPresent
2323
env: # user defined environments
@@ -28,21 +28,54 @@ spec:
2828
- name: "aggregation_algorithm"
2929
value: "mistnet"
3030
- name: "batch_size"
31+
value: "32"
3132
resources: # user defined resources
3233
limits:
3334
memory: 8Gi
3435
trainingWorkers:
3536
- dataset:
36-
name: "coco-dataset"
37+
name: "coco-dataset-1"
3738
template:
3839
spec:
3940
nodeName: "edge-node"
4041
containers:
41-
- image: kubeedge/sedna-fl-train:mistnetyolo
42+
- image: kubeedge/sedna-example-federated-learning-mistnet-yolo-client:v0.4.0
4243
name: train-worker
4344
imagePullPolicy: IfNotPresent
4445
args: [ "-i", "1" ]
4546
env: # user defined environments
47+
- name: "cut_layer"
48+
value: "4"
49+
- name: "epsilon"
50+
value: "100"
51+
- name: "aggregation_algorithm"
52+
value: "mistnet"
53+
- name: "batch_size"
54+
value: "32"
55+
- name: "learning_rate"
56+
value: "0.001"
57+
- name: "epochs"
58+
value: "1"
59+
resources: # user defined resources
60+
limits:
61+
memory: 2Gi
62+
- dataset:
63+
name: "coco-dataset-2"
64+
template:
65+
spec:
66+
nodeName: "edge-node"
67+
containers:
68+
- image: kubeedge/sedna-example-federated-learning-mistnet-yolo-client:v0.4.0
69+
name: train-worker
70+
imagePullPolicy: IfNotPresent
71+
args: [ "-i", "2" ]
72+
env: # user defined environments
73+
- name: "cut_layer"
74+
value: "4"
75+
- name: "epsilon"
76+
value: "100"
77+
- name: "aggregation_algorithm"
78+
value: "mistnet"
4679
- name: "batch_size"
4780
value: "32"
4881
- name: "learning_rate"

examples/build_image.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
cd "$(dirname "${BASH_SOURCE[0]}")"
1818

1919
IMAGE_REPO=${IMAGE_REPO:-kubeedge}
20-
IMAGE_TAG=${IMAGE_TAG:-v0.3.0}
20+
IMAGE_TAG=${IMAGE_TAG:-v0.4.0}
2121

2222
EXAMPLE_REPO_PREFIX=${IMAGE_REPO}/sedna-example-
2323

2424
dockerfiles=(
25+
federated-learning-mistnet-yolo-aggregator.Dockerfile
26+
federated-learning-mistnet-yolo-client.Dockerfile
2527
federated-learning-surface-defect-detection-aggregation.Dockerfile
2628
federated-learning-surface-defect-detection-train.Dockerfile
2729
incremental-learning-helmet-detection.Dockerfile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM tensorflow/tensorflow:1.15.4
2+
3+
RUN apt update \
4+
&& apt install -y libgl1-mesa-glx git
5+
6+
COPY ./lib/requirements.txt /home
7+
8+
RUN python -m pip install --upgrade pip
9+
10+
RUN pip install -r /home/requirements.txt
11+
12+
ENV PYTHONPATH "/home/lib:/home/plato:/home/plato/packages/yolov5"
13+
14+
COPY ./lib /home/lib
15+
RUN git clone https://github.com/TL-System/plato.git /home/plato
16+
17+
RUN pip install -r /home/plato/requirements.txt
18+
RUN pip install -r /home/plato/packages/yolov5/requirements.txt
19+
20+
WORKDIR /home/work
21+
COPY examples/federated_learning/yolov5_coco128_mistnet /home/work/
22+
23+
CMD ["/bin/sh", "-c", "ulimit -n 50000; python aggregate.py"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM tensorflow/tensorflow:1.15.4
2+
3+
RUN apt update \
4+
&& apt install -y libgl1-mesa-glx git
5+
6+
COPY ./lib/requirements.txt /home
7+
8+
RUN python -m pip install --upgrade pip
9+
10+
RUN pip install -r /home/requirements.txt
11+
12+
ENV PYTHONPATH "/home/lib:/home/plato:/home/plato/packages/yolov5"
13+
14+
COPY ./lib /home/lib
15+
RUN git clone https://github.com/TL-System/plato.git /home/plato
16+
17+
RUN pip install -r /home/plato/requirements.txt
18+
RUN pip install -r /home/plato/packages/yolov5/requirements.txt
19+
20+
WORKDIR /home/work
21+
COPY examples/federated_learning/yolov5_coco128_mistnet /home/work/
22+
23+
ENTRYPOINT ["python", "train.py"]

examples/federated_learning/surface_defect_detection/training_worker/train.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
1514
import os
1615

1716
import numpy as np
@@ -74,6 +73,7 @@ def main():
7473
learning_rate=learning_rate,
7574
validation_split=validation_split
7675
)
76+
7777
return train_jobs
7878

7979

0 commit comments

Comments
 (0)