云服务器内容精选

  • 访问边缘服务 当边缘服务和边缘节点的状态都处于“运行中”状态,表示边缘服务已在边缘节点成功部署。 您可以通过以下两种方式,在能够访问到边缘节点的网络环境中,对部署在边缘节点上的边缘服务发起预测请求。 方式一:使用图形界面的软件进行预测(以Postman为例) 方式二:使用curl命令发送预测请求 通过方式一和方式二,边缘服务无需安全认证即可访问。如果用户需要设置安全认证,请选择使用自定义镜像创建的AI应用,具体操作请参考官方指导。在制作自定义镜像时,可参考Flask文档使用Flask设计RESTful的认证。
  • 方式一:使用图形界面的软件进行预测(以Postman为例) 下载Postman软件并安装,您可以直接在Chrome浏览器添加Postman扩展程序(也可使用其它支持发送post请求的软件)。 打开Postman,如图1所示。 图1 Postman软件界面 在Postman界面填写参数,以图像分类举例说明。 选择POST任务,将某个边缘节点的调用地址(通过边缘服务详情界面-节点信息页签查看)复制到POST后面的方框。 图2 POST参数填写 在Body页签,根据AI应用的输入参数不同,可分为“文件输入”或“文本输入”。 文件输入 选择“form-data”。在“KEY”值填写AI应用的入参,比如本例中预测图片的参数为“images”。然后在“VALUE”值,选择文件,上传一张待预测图片(当前仅支持单张图片预测)。 图3 填写Body配置 文本输入 选择“raw”,选择JSON(application/json)类型,在下方文本框中填写请求体,请求体样例如下。 { "meta": { "uuid": "10eb0091-887f-4839-9929-cbc884f1e20e" }, "data": { "req_data": [ { "sepal_length": 3, "sepal_width": 1, "petal_length": 2.2, "petal_width": 4 } ] } } 其中,“meta”中可携带“uuid”,返回预测结果时回传此“uuid”用于跟踪请求,如无此需要可不填写meta。“data”包含了一个“req_data”的数组,可传入单条或多条请求数据,其中每个数据的参数由AI应用决定,比如本例中的“sepal_length”、“sepal_width”等。 参数填写完成,单击“Send”发送请求,结果会在Response下的对话框里显示。 文件输入形式的预测结果样例如图4所示,返回结果的字段值根据不同AI应用可能有所不同。 图4 边缘服务文件输入预测结果 文本输入形式的预测结果样例如图5所示,请求体包含“meta”及“data”。如输入请求中包含“uuid”,则输出结果中回传此“uuid”。如未输入,则为空。“data”包含了一个“req_data”的数组,可传入单条或多条请求数据,其中每个数据的参数由AI应用决定,比如本例中的“sepal_length”、“sepal_width”等。 图5 边缘服务文本输入预测结果
  • 响应参数 状态码: 200 表15 响应Body参数 参数 参数类型 描述 tasks Array of TaskResponse objects VIAS平台创建作业的作业id列表 表16 TaskResponse 参数 参数类型 描述 id String VIAS平台创建的作业id。 状态码: 400 表17 响应Body参数 参数 参数类型 描述 error_code String 错误码。 error_msg String 错误信息描述。 detail String 错误详情。 params Array of strings 错误参数列举。 数组长度:0 - 1 reason String 错误原因。 advice String 建议。 状态码: 500 表18 响应Body参数 参数 参数类型 描述 error_code String 错误码。 error_msg String 错误信息描述。 detail String 错误详情。 params Array of strings 错误参数列举。 数组长度:0 - 1 reason String 错误原因。 advice String 建议。
  • 请求示例 边缘视频车辆作业创建,使用输入源为video_source,输出为webhook。 POST /v2/{project_id}/services/c-vehicle-detection-edge/tasks { "name" : "vehicle-task", "description" : "vehicle detection task test", "input" : { "type" : "video_source", "data" : [ { "video_source_id" : "xxxxxxx-xxxxxxx-xxxxxxx-xxxxx-xxxxxx" } ] }, "output" : { "webhook" : { "url" : "https://127.0.0.1:8080/webhook", "headers" : { "x-auth-token" : "tokentest" } } }, "service_version" : "3.0", "resource_order_id" : "840a5cf90d4a4bbaa71f251dfe8fe64e", "config" : { "common" : { "target_roi" : "{\"lines\":[{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}],\"polygons\":[{\"data\":[[487,465],[1850,450],[1905,1013],[515,1050]]}]}", "license_plate" : { "local_city" : "B", "local_province" : "津" }, "output_image_sw" : 1, "image_compression_ratio" : 100 } } } 边缘视频车辆作业创建,使用输入源为VCN,输出为dis。 POST /v2/{project_id}/services/c-vehicle-detection-edge/tasks { "name" : "vehicle-task", "description" : "vehicle detection task test", "input" : { "type" : "vcn", "data" : [ { "device_id" : "aec5857c-222f-4aa9-be39-23654e118886", "stream_type" : 2 } ], "vcn" : { "ip" : "127.0.0.1", "port" : 8080, "username" : "vcntest", "password" : "123456abcd" } }, "output" : { "dis" : { "stream_name" : "dis-test" } }, "service_version" : "3.0", "resource_order_id" : "840a5cf90d4a4bbaa71f251dfe8fe64e", "config" : { "common" : { "target_roi" : "{\"lines\":[{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}],\"polygons\":[{\"data\":[[487,465],[1850,450],[1905,1013],[515,1050]]}]}", "license_plate" : { "local_city" : "B", "local_province" : "津" }, "output_image_sw" : 1, "image_compression_ratio" : 100 } } } 边缘视频车辆作业创建,使用输入源为边缘摄像头,输出为dis。 POST /v2/{project_id}/services/c-vehicle-detection-edge/tasks { "name" : "vehicle-task", "description" : "vehicle detection task test", "input" : { "type" : "edgecamera", "data" : [ { "id" : "aec5857c-222f-4aa9-be39-23654e118886", "index" : 0 } ] }, "output" : { "dis" : { "stream_name" : "dis-test" } }, "service_version" : "3.0", "resource_order_id" : "840a5cf90d4a4bbaa71f251dfe8fe64e", "config" : { "common" : { "target_roi" : "{\"lines\":[{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}],\"polygons\":[{\"data\":[[487,465],[1850,450],[1905,1013],[515,1050]]}]}", "license_plate" : { "local_city" : "B", "local_province" : "津" }, "output_image_sw" : 1, "image_compression_ratio" : 100 } } } 边缘视频车辆作业创建,使用输入源为restful,输出为webhook。 POST /v2/{project_id}/services/c-vehicle-detection-edge/tasks { "name" : "vehicle-task", "description" : "vehicle detection task test", "input" : { "type" : "restful", "data" : [ { "url" : "https://restfultest", "certificate_check" : false, "node_id" : "aec5857c-222f-4aa9-be39-23654e118886", "rtsp_path_in_response" : "http://testpath" } ] }, "output" : { "webhook" : { "url" : "https://127.0.0.1:8080/webhook", "headers" : { "x-auth-token" : "tokentest" } } }, "service_version" : "3.0", "resource_order_id" : "840a5cf90d4a4bbaa71f251dfe8fe64e", "config" : { "common" : { "target_roi" : "{\"lines\":[{\"data\":[[50,756],[100,616]],\"properties\":{\"type\":0}},{\"data\":[[50,256],[100,116]],\"properties\":{\"type\":1}}],\"polygons\":[{\"data\":[[487,465],[1850,450],[1905,1013],[515,1050]]}]}", "license_plate" : { "local_city" : "B", "local_province" : "津" }, "output_image_sw" : 1, "image_compression_ratio" : 100 } } }
  • 边缘服务器安装Docker docker 查看docker版本,版本建议20以上 sudo docker --version 安装教程 sudo apt updatesudo apt install docker-ce docker-ce-cli containerd.io nvidia-docker 查看nvidia-docker版本 sudo nvidia-docker --version 安装教程参考:https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#install-guide distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \&& curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container.list | \sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.listsudo apt-get updatesudo apt-get install -y nvidia-docker2sudo systemctl restart docker 父主题: 边缘服务部署
  • 环境要求 安装边缘节点的服务器需要与设备在同一网域,因此您可以 局域网:使用两台电脑(一台Windows,一台Linux),或者在一台Windows电脑上使用虚拟化软件安装Linux(网卡需要设置为桥接模式)。 公网:分别使用两台拥有公网的Window和Linux电脑,推荐购买两台ECS服务器。 其他要求: 安装边缘节点的电脑需为Linux,推荐使用CentOS 7(不推荐CentOS 8,因CentOS 8缺少边缘软件依赖组件)。 安装边缘节点的电脑需要安装docker且内存不小于1G,docker要求版本大于17.06.0,推荐18.06.3,不推荐18.09.0(该版本有多处bug)。 开放7883端口。
  • 更新模型版本时,预测功能不可用? 针对某一部署的边缘服务,如果在更新模型版本时,即编辑边缘服务,修改其使用的模型版本,导致此边缘服务的预测功能暂不可用。 针对此场景,由于更新了模型版本,边缘服务将重新部署,处于部署中的边缘服务,则无法使用预测功能。即更新模型版本,会导致预测功能中断。等待边缘服务重新处于运行中时,预测功能恢复正常。 补充说明一点,针对在线服务和批量服务,当更新模型版本时,不会中断预测功能。 父主题: 边缘服务