|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- # Using Lifelong Learning in Campus Robot Delivery Scenario
-
- ## Introduction
- This example introduces how to use Sedna lifelong learning to implement the lifelong learning delivery task of the robot in the campus.
-
- This demo mainly shows:
- 1. Lifelong learning unseen task recognition algorithm (prediction) can identify and collect unseen task samples.
- 2. Lifelong learning unseen task recognition algorithm (detection) can trigger alarms to remind robot admin that emergency response is required.
- 3. Lifelong learning unseen task training algorithm improves the inference accuracy of known categories and the ability to identify new categories.
-
- ## System Architecture
-
- ### Install Sedna
- Follow the [Sedna installation document](/docs/setup/install.md) to install Sedna.
-
- ### Prepare Dataset
- Step1: download [data.txt](https://kubeedge.obs.cn-north-1.myhuaweicloud.com:443/sedna-robo/data.txt?AWSAccessKeyId=EMPTKHQUGPO2CDUFD2YR&Expires=1697698966&Signature=s42sKZVewIP/kgLc4dEzjNCRXfk%3D)
- and upload it to a specfied s3 directory. In this example, the directory is s3://kubeedge/sedna-robo/sedna_data.
-
- Step2: download and decompress [sedna_data.zip](https://kubeedge.obs.cn-north-1.myhuaweicloud.com:443/sedna-robo/sedna_data.zip?AWSAccessKeyId=EMPTKHQUGPO2CDUFD2YR&Expires=1697700463&Signature=9OlCC8qBcQr8LfX1ptbsr7nhU5s%3D),
- then upload the training images in it to the s3 directory where data.txt is stored.
-
- ### Prepare Images
- This example uses these images:
-
- 1. training worker: swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo:v0.1.1
- 2. evaluate worker: swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo:v0.1.1
- 3. inference worker: swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo-infer:v0.1.1
-
- These images are generated by the script [build_images.sh](/examples/build_image.sh).
-
- ### Create Lifelong Learning Job
-
- #### Preparations
- Before this, user must provide an s3 directory for storage which is denoted as "s3_prefix" in this example, by setting environment variable s3_prefix.
- ```
- s3_prefix=$s3_prefix
- cloud_image=swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo:v0.1.1
- edge_image=swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo-infer:v0.1.1
- data_url=$s3_prefix/sedna_data/data.txt
-
- DATA_NODE=sedna-mini-control-plane
- TRAIN_NODE=sedna-mini-control-plane
- EVAL_NODE=sedna-mini-control-plane
- INFER_NODE=sedna-mini-control-plane
- OUTPUT=$s3_prefix/lifelonglearningjob/output
- job_name=robo-demo
- ```
- #### Create s3 storage resources
- Before this, users must generate the S3_ENDPOINT, ACCESS_KEY_ID and SECRET_ACCESS_KEY of their own s3 accounts and set environment
- variables S3_ENDPOINT, ACCESS_KEY_ID and SECRET_ACCESS_KEY.
- ```
- action=${1:-create}
-
- kubectl $action -f - <<EOF
- apiVersion: v1
- stringData:
- ACCESS_KEY_ID: $ACCESS_KEY_ID
- SECRET_ACCESS_KEY: $SECRET_ACCESS_KEY
- kind: Secret
- metadata:
- name: my
- annotations:
- s3-endpoint: $S3_ENDPOINT
- type: Opaque
- EOF
- ```
-
- #### Create Initial Dataset Resource
- ```
- kubectl $action -f - <<EOF
- apiVersion: sedna.io/v1alpha1
- kind: Dataset
- metadata:
- name: lifelong-dataset-robo
- spec:
- url: "$data_url"
- format: "txt"
- nodeName: "$DATA_NODE"
- credentialName: my
- EOF
- ```
-
- #### Create robot-dog-delivery Lifelong Learning Job
- ```
- action=${1:-create}
-
- kubectl $action -f - <<EOF
- apiVersion: sedna.io/v1alpha1
- kind: LifelongLearningJob
- metadata:
- name: $job_name
- spec:
- dataset:
- name: "lifelong-dataset-robo"
- trainProb: 0.8
- trainSpec:
- template:
- spec:
- nodeName: $TRAIN_NODE
- dnsPolicy: ClusterFirstWithHostNet
- containers:
- - image: $cloud_image
- name: train-worker
- imagePullPolicy: IfNotPresent
- args: ["sedna_train.py"]
- env:
- - name: "train_ratio"
- value: "0.9"
- - name: "BACKEND_TYPE"
- value: "PYTORCH"
- resources:
- limits:
- cpu: 6
- memory: 6Gi
- requests:
- cpu: 3
- memory: 3Gi
- volumeMounts:
- - mountPath: /dev/shm
- name: cache-volume
- volumes:
- - emptyDir:
- medium: Memory
- sizeLimit: 128Mi
- name: cache-volume
- trigger:
- checkPeriodSeconds: 30
- timer:
- start: 00:00
- end: 24:00
- condition:
- operator: ">"
- threshold: 100
- metric: num_of_samples
- evalSpec:
- template:
- spec:
- nodeName: $EVAL_NODE
- dnsPolicy: ClusterFirstWithHostNet
- containers:
- - image: $cloud_image
- name: eval-worker
- imagePullPolicy: IfNotPresent
- args: ["sedna_evaluate.py"]
- env:
- - name: "operator"
- value: "<"
- - name: "model_threshold" # Threshold for filtering deploy models
- value: "0"
- - name: "BACKEND_TYPE"
- value: "PYTORCH"
- resources:
- limits:
- cpu: 6
- memory: 6Gi
- requests:
- cpu: 3
- memory: 3Gi
- deploySpec:
- template:
- spec:
- nodeName: $INFER_NODE
- dnsPolicy: ClusterFirstWithHostNet
- hostNetwork: true
- containers:
- - image: $edge_image
- name: infer-worker
- imagePullPolicy: IfNotPresent
- env:
- - name: "BIG_MODEL_IP"
- value: "http://94.74.91.114"
- - name: "BIG_MODEL_PORT"
- value: "30001"
- - name: "RUN_FILE"
- value: "integration_main.py"
- resources: # user defined resources
- limits:
- cpu: 6
- memory: 6Gi
- requests:
- cpu: 3
- memory: 3Gi
-
- credentialName: my
- outputDir: $OUTPUT/$job_name
- EOF
- ```
-
- ### Check Lifelong Learning Status
-
- ```
- kubectl get lifelonglearningjob
- ```
-
- ### Effect Display
-
-
-
-
-
|