You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 6.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. # Using Lifelong Learning in Campus Robot Delivery Scenario
  2. ## Introduction
  3. This example introduces how to use Sedna lifelong learning to implement the lifelong learning delivery task of the robot in the campus.
  4. This demo mainly shows:
  5. 1. Lifelong learning unseen task recognition algorithm (prediction) can identify and collect unseen task samples.
  6. 2. Lifelong learning unseen task recognition algorithm (detection) can trigger alarms to remind robot admin that emergency response is required.
  7. 3. Lifelong learning unseen task training algorithm improves the inference accuracy of known categories and the ability to identify new categories.
  8. ## System Architecture
  9. ### Install Sedna
  10. Follow the [Sedna installation document](/docs/setup/install.md) to install Sedna.
  11. ### Prepare Dataset
  12. 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)
  13. and upload it to a specfied s3 directory. In this example, the directory is s3://kubeedge/sedna-robo/sedna_data.
  14. 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),
  15. then upload the training images in it to the s3 directory where data.txt is stored.
  16. ### Prepare Images
  17. This example uses these images:
  18. 1. training worker: swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo:v0.1.1
  19. 2. evaluate worker: swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo:v0.1.1
  20. 3. inference worker: swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo-infer:v0.1.1
  21. These images are generated by the script [build_images.sh](/examples/build_image.sh).
  22. ### Create Lifelong Learning Job
  23. #### Preparations
  24. 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.
  25. ```
  26. s3_prefix=$s3_prefix
  27. cloud_image=swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo:v0.1.1
  28. edge_image=swr.cn-south-1.myhuaweicloud.com/sedna/sedna-robo-infer:v0.1.1
  29. data_url=$s3_prefix/sedna_data/data.txt
  30. DATA_NODE=sedna-mini-control-plane
  31. TRAIN_NODE=sedna-mini-control-plane
  32. EVAL_NODE=sedna-mini-control-plane
  33. INFER_NODE=sedna-mini-control-plane
  34. OUTPUT=$s3_prefix/lifelonglearningjob/output
  35. job_name=robo-demo
  36. ```
  37. #### Create s3 storage resources
  38. Before this, users must generate the S3_ENDPOINT, ACCESS_KEY_ID and SECRET_ACCESS_KEY of their own s3 accounts and set environment
  39. variables S3_ENDPOINT, ACCESS_KEY_ID and SECRET_ACCESS_KEY.
  40. ```
  41. action=${1:-create}
  42. kubectl $action -f - <<EOF
  43. apiVersion: v1
  44. stringData:
  45. ACCESS_KEY_ID: $ACCESS_KEY_ID
  46. SECRET_ACCESS_KEY: $SECRET_ACCESS_KEY
  47. kind: Secret
  48. metadata:
  49. name: my
  50. annotations:
  51. s3-endpoint: $S3_ENDPOINT
  52. type: Opaque
  53. EOF
  54. ```
  55. #### Create Initial Dataset Resource
  56. ```
  57. kubectl $action -f - <<EOF
  58. apiVersion: sedna.io/v1alpha1
  59. kind: Dataset
  60. metadata:
  61. name: lifelong-dataset-robo
  62. spec:
  63. url: "$data_url"
  64. format: "txt"
  65. nodeName: "$DATA_NODE"
  66. credentialName: my
  67. EOF
  68. ```
  69. #### Create robot-dog-delivery Lifelong Learning Job
  70. ```
  71. action=${1:-create}
  72. kubectl $action -f - <<EOF
  73. apiVersion: sedna.io/v1alpha1
  74. kind: LifelongLearningJob
  75. metadata:
  76. name: $job_name
  77. spec:
  78. dataset:
  79. name: "lifelong-dataset-robo"
  80. trainProb: 0.8
  81. trainSpec:
  82. template:
  83. spec:
  84. nodeName: $TRAIN_NODE
  85. dnsPolicy: ClusterFirstWithHostNet
  86. containers:
  87. - image: $cloud_image
  88. name: train-worker
  89. imagePullPolicy: IfNotPresent
  90. args: ["sedna_train.py"]
  91. env:
  92. - name: "train_ratio"
  93. value: "0.9"
  94. - name: "BACKEND_TYPE"
  95. value: "PYTORCH"
  96. resources:
  97. limits:
  98. cpu: 6
  99. memory: 6Gi
  100. requests:
  101. cpu: 3
  102. memory: 3Gi
  103. volumeMounts:
  104. - mountPath: /dev/shm
  105. name: cache-volume
  106. volumes:
  107. - emptyDir:
  108. medium: Memory
  109. sizeLimit: 128Mi
  110. name: cache-volume
  111. trigger:
  112. checkPeriodSeconds: 30
  113. timer:
  114. start: 00:00
  115. end: 24:00
  116. condition:
  117. operator: ">"
  118. threshold: 100
  119. metric: num_of_samples
  120. evalSpec:
  121. template:
  122. spec:
  123. nodeName: $EVAL_NODE
  124. dnsPolicy: ClusterFirstWithHostNet
  125. containers:
  126. - image: $cloud_image
  127. name: eval-worker
  128. imagePullPolicy: IfNotPresent
  129. args: ["sedna_evaluate.py"]
  130. env:
  131. - name: "operator"
  132. value: "<"
  133. - name: "model_threshold" # Threshold for filtering deploy models
  134. value: "0"
  135. - name: "BACKEND_TYPE"
  136. value: "PYTORCH"
  137. resources:
  138. limits:
  139. cpu: 6
  140. memory: 6Gi
  141. requests:
  142. cpu: 3
  143. memory: 3Gi
  144. deploySpec:
  145. template:
  146. spec:
  147. nodeName: $INFER_NODE
  148. dnsPolicy: ClusterFirstWithHostNet
  149. hostNetwork: true
  150. containers:
  151. - image: $edge_image
  152. name: infer-worker
  153. imagePullPolicy: IfNotPresent
  154. env:
  155. - name: "BIG_MODEL_IP"
  156. value: "http://94.74.91.114"
  157. - name: "BIG_MODEL_PORT"
  158. value: "30001"
  159. - name: "RUN_FILE"
  160. value: "integration_main.py"
  161. resources: # user defined resources
  162. limits:
  163. cpu: 6
  164. memory: 6Gi
  165. requests:
  166. cpu: 3
  167. memory: 3Gi
  168. credentialName: my
  169. outputDir: $OUTPUT/$job_name
  170. EOF
  171. ```
  172. ### Check Lifelong Learning Status
  173. ```
  174. kubectl get lifelonglearningjob
  175. ```
  176. ### Effect Display