|
| 1 | + |
| 2 | +# Quick Start |
| 3 | + |
| 4 | + |
| 5 | +The following is showing how to run a joint inference job by sedna. |
| 6 | +## Quick Start |
| 7 | + |
| 8 | +#### 0. Check the Environment |
| 9 | + |
| 10 | +For Sedna all-in-one installation, it requires you: |
| 11 | + - 1 VM **(one machine is OK, cluster is not required)** |
| 12 | + - 2 CPUs or more |
| 13 | + - 2GB+ free memory, depends on node number setting |
| 14 | + - 10GB+ free disk space |
| 15 | + - Internet connection(docker hub, github etc.) |
| 16 | + - Linux platform, such as ubuntu/centos |
| 17 | + - Docker 17.06+ |
| 18 | + |
| 19 | +you can check the docker version by the following command, |
| 20 | +```bash |
| 21 | +docker -v |
| 22 | +``` |
| 23 | +after doing that, the output will be like this, that means your version fits the bill. |
| 24 | +``` |
| 25 | +Docker version 19.03.6, build 369ce74a3c |
| 26 | +``` |
| 27 | + |
| 28 | + |
| 29 | +#### 1. Deploy Sedna |
| 30 | +Sedna provides three deployment methods, which can be selected according to your actual situation: |
| 31 | + |
| 32 | +- [Install Sedna AllinOne](setup/all-in-one.md). (used for development, here we use it) |
| 33 | +- [Install Sedna local up](setup/local-up.md). |
| 34 | +- [Install Sedna on a cluster](setup/install.md). |
| 35 | + |
| 36 | +The [all-in-one script](/scripts/installation/all-in-one.sh) is used to install Sedna along with a mini Kubernetes environment locally, including: |
| 37 | + - A Kubernetes v1.21 cluster with multi worker nodes, default zero worker node. |
| 38 | + - KubeEdge with multi edge nodes, default is latest KubeEdge and one edge node. |
| 39 | + - Sedna, default is the latest version. |
| 40 | + |
| 41 | + ```bash |
| 42 | + curl https://raw.githubusercontent.com/kubeedge/sedna/master/scripts/installation/all-in-one.sh | NUM_EDGE_NODES=1 bash - |
| 43 | + ``` |
| 44 | + |
| 45 | +Then you get two nodes `sedna-mini-control-plane` and `sedna-mini-edge0`,you can get into each node by following command: |
| 46 | + |
| 47 | +```bash |
| 48 | +# get into cloud node |
| 49 | +docker exec -it sedna-mini-control-plane bash |
| 50 | +``` |
| 51 | + |
| 52 | +```bash |
| 53 | +# get into edge node |
| 54 | +docker exec -it sedna-mini-edge0 bash |
| 55 | +``` |
| 56 | + |
| 57 | +#### 1. Prepare Data and Model File |
| 58 | + |
| 59 | +* step1: download [little model](https://kubeedge.obs.cn-north-1.myhuaweicloud.com/examples/helmet-detection-inference/little-model.tar.gz) to your edge node. |
| 60 | + |
| 61 | +``` |
| 62 | +mkdir -p /data/little-model |
| 63 | +cd /data/little-model |
| 64 | +wget https://kubeedge.obs.cn-north-1.myhuaweicloud.com/examples/helmet-detection-inference/little-model.tar.gz |
| 65 | +tar -zxvf little-model.tar.gz |
| 66 | +``` |
| 67 | + |
| 68 | +* step2: download [big model](https://kubeedge.obs.cn-north-1.myhuaweicloud.com/examples/helmet-detection-inference/big-model.tar.gz) to your cloud node. |
| 69 | + |
| 70 | +``` |
| 71 | +mkdir -p /data/big-model |
| 72 | +cd /data/big-model |
| 73 | +wget https://kubeedge.obs.cn-north-1.myhuaweicloud.com/examples/helmet-detection-inference/big-model.tar.gz |
| 74 | +tar -zxvf big-model.tar.gz |
| 75 | +``` |
| 76 | + |
| 77 | +#### 2. Create Big Model Resource Object for Cloud |
| 78 | +In cloud node: |
| 79 | +``` |
| 80 | +kubectl create -f - <<EOF |
| 81 | +apiVersion: sedna.io/v1alpha1 |
| 82 | +kind: Model |
| 83 | +metadata: |
| 84 | + name: helmet-detection-inference-big-model |
| 85 | + namespace: default |
| 86 | +spec: |
| 87 | + url: "/data/big-model/yolov3_darknet.pb" |
| 88 | + format: "pb" |
| 89 | +EOF |
| 90 | +``` |
| 91 | + |
| 92 | +#### 3. Create Little Model Resource Object for Edge |
| 93 | +In cloud node: |
| 94 | +``` |
| 95 | +kubectl create -f - <<EOF |
| 96 | +apiVersion: sedna.io/v1alpha1 |
| 97 | +kind: Model |
| 98 | +metadata: |
| 99 | + name: helmet-detection-inference-little-model |
| 100 | + namespace: default |
| 101 | +spec: |
| 102 | + url: "/data/little-model/yolov3_resnet18.pb" |
| 103 | + format: "pb" |
| 104 | +EOF |
| 105 | +``` |
| 106 | + |
| 107 | +#### 4. Create JointInferenceService |
| 108 | + |
| 109 | +Note the setting of the following parameters, which have to same as the script [little_model.py](/examples/joint_inference/helmet_detection_inference/little_model/little_model.py): |
| 110 | +- hardExampleMining: set hard example algorithm from {IBT, CrossEntropy} for inferring in edge side. |
| 111 | +- video_url: set the url for video streaming. |
| 112 | +- all_examples_inference_output: set your output path for the inference results. |
| 113 | +- hard_example_edge_inference_output: set your output path for results of inferring hard examples in edge side. |
| 114 | +- hard_example_cloud_inference_output: set your output path for results of inferring hard examples in cloud side. |
| 115 | + |
| 116 | +Make preparation in edge node |
| 117 | +``` |
| 118 | +mkdir -p /joint_inference/output |
| 119 | +``` |
| 120 | + |
| 121 | +Create joint inference service |
| 122 | +``` |
| 123 | +CLOUD_NODE="sedna-mini-control-plane" |
| 124 | +EDGE_NODE="sedna-mini-edge0" |
| 125 | +
|
| 126 | +kubectl create -f https://raw.githubusercontent.com/jaypume/sedna/main/examples/joint_inference/helmet_detection_inference/helmet_detection_inference.yaml |
| 127 | +``` |
| 128 | + |
| 129 | + |
| 130 | +#### 5. Check Joint Inference Status |
| 131 | + |
| 132 | +``` |
| 133 | +kubectl get jointinferenceservices.sedna.io |
| 134 | +``` |
| 135 | + |
| 136 | +#### 6. Mock Video Stream for Inference in Edge Side |
| 137 | + |
| 138 | +* step1: install the open source video streaming server [EasyDarwin](https://github.com/EasyDarwin/EasyDarwin/tree/dev). |
| 139 | +* step2: start EasyDarwin server. |
| 140 | +* step3: download [video](https://kubeedge.obs.cn-north-1.myhuaweicloud.com/examples/helmet-detection-inference/video.tar.gz). |
| 141 | +* step4: push a video stream to the url (e.g., `rtsp://localhost/video`) that the inference service can connect. |
| 142 | + |
| 143 | +``` |
| 144 | +wget https://github.com/EasyDarwin/EasyDarwin/releases/download/v8.1.0/EasyDarwin-linux-8.1.0-1901141151.tar.gz |
| 145 | +tar -zxvf EasyDarwin-linux-8.1.0-1901141151.tar.gz |
| 146 | +cd EasyDarwin-linux-8.1.0-1901141151 |
| 147 | +./start.sh |
| 148 | +
|
| 149 | +mkdir -p /data/video |
| 150 | +cd /data/video |
| 151 | +wget https://kubeedge.obs.cn-north-1.myhuaweicloud.com/examples/helmet-detection-inference/video.tar.gz |
| 152 | +tar -zxvf video.tar.gz |
| 153 | +
|
| 154 | +ffmpeg -re -i /data/video/video.mp4 -vcodec libx264 -f rtsp rtsp://localhost/video |
| 155 | +``` |
| 156 | + |
| 157 | +### Check Inference Result |
| 158 | + |
| 159 | +You can check the inference results in the output path (e.g. `/joint_inference/output`) defined in the JointInferenceService config. |
| 160 | +* the result of edge inference vs the result of joint inference |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | +## API |
| 165 | + |
| 166 | +- control-plane: Please refer to this [link](api/crd). |
| 167 | +- Lib: Please refer to this [link](api/lib). |
| 168 | + |
| 169 | +## Contributing |
| 170 | + |
| 171 | +Contributions are very welcome! |
| 172 | + |
| 173 | +- control-plane: Please refer to this [link](contributing/control-plane/development.md). |
| 174 | +- Lib: Please refer to this [link](contributing/lib/development.md). |
| 175 | + |
| 176 | +## Community |
| 177 | + |
| 178 | +Sedna is an open source project and in the spirit of openness and freedom, we welcome new contributors to join us. |
| 179 | +You can get in touch with the community according to the ways: |
| 180 | +* [Github Issues](https://github.com/kubeedge/sedna/issues) |
| 181 | +* [Regular Community Meeting](https://zoom.us/j/4167237304) |
| 182 | +* [slack channel](https://app.slack.com/client/TDZ5TGXQW/C01EG84REVB/details) |
| 183 | + |
0 commit comments