# Using Federated Learning Job in Surface Defect Detection Scenario This case introduces how to use federated learning job in surface defect detection scenario. In the safety surface defect detection, data is scattered in different places (such as server node, camera or others) and cannot be aggregated due to data privacy and bandwidth. As a result, we cannot use all the data for training. Using Federated Learning, we can solve the problem. Each place uses its own data for model training ,uploads the weight to the cloud for aggregation, and obtains the aggregation result for model update. ## Surface Defect Detection Experiment > Assume that there are two edge nodes and a cloud node. Data on the edge nodes cannot be migrated to the cloud due to privacy issues. > Base on this scenario, we will demonstrate the surface inspection. ### Prepare Nodes ``` CLOUD_NODE="cloud-node-name" EDGE1_NODE="edge1-node-name" EDGE2_NODE="edge2-node-name" ``` ### Install Sedna Follow the [Sedna installation document](/docs/setup/install.md) to install Sedna. ### Prepare Dataset Download [dataset](https://github.com/abin24/Magnetic-tile-defect-datasets.) and the [label file](/examples/federated_learning/surface_defect_detection/data/1.txt) to `/data` of ```EDGE1_NODE```. ``` mkdir -p /data cd /data git clone https://github.com/abin24/Magnetic-tile-defect-datasets..git Magnetic-tile-defect-datasets curl -o 1.txt https://raw.githubusercontent.com/kubeedge/sedna/main/examples/federated_learning/surface_defect_detection/data/1.txt ``` Download [dataset](https://github.com/abin24/Magnetic-tile-defect-datasets.) and the [label file](/examples/federated_learning/surface_defect_detection/data/2.txt) to `/data` of ```EDGE2_NODE```. ``` mkdir -p /data cd /data git clone https://github.com/abin24/Magnetic-tile-defect-datasets..git Magnetic-tile-defect-datasets curl -o 2.txt https://raw.githubusercontent.com/kubeedge/sedna/main/examples/federated_learning/surface_defect_detection/data/2.txt ``` ### Prepare Images This example uses these images: 1. aggregation worker: ```kubeedge/sedna-example-federated-learning-surface-defect-detection-aggregation:v0.3.0``` 2. train worker: ```kubeedge/sedna-example-federated-learning-surface-defect-detection-train:v0.3.0``` These images are generated by the script [build_images.sh](/examples/build_image.sh). ### Create Federated Learning Job #### Create Dataset create dataset for `$EDGE1_NODE` ``` kubectl create -f - <