In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Brief introduction
First of all, we introduce several important concepts that appear in this article:
Function computing (Function Compute): function computing is an event-driven service. Through function calculation, users do not need to manage the operation of the server, but only need to write code and upload. The function calculation prepares the computing resources and runs the user code in an elastic way, while the user only needs to pay according to the resources consumed by the actual code. Function calculation for more information
Functional Workflow (Function Flow): a functional workflow is a fully managed cloud service used to coordinate the execution of multiple distributed tasks. Users can arrange distributed tasks in order, branch, parallel, etc. FnF will reliably coordinate task execution according to the set steps, track the state transition of each task, and execute user-defined retry logic if necessary to ensure the smooth completion of the workflow. Function Workflow reference for more information
This article will focus on how to quickly deploy a timed offline batch processing image file and face tagging service through function calculation and function workflow.
Activate the service
Free function calculation, pay by quantity, function calculation has a large amount of free. Free function workflow, pay by quantity, this product is in the public trial phase, can be used free of charge. Activate object storage for free and pay by quantity.
Solution
The process is as follows:
Set the timing trigger and trigger the function in the function calculation. After the function is triggered, the process in the function workflow is called once.
The process in the function workflow is executed:
Call the function in the function calculation to enumerate the list of picture files under the root path of OSS Bucket. For the list of files listed in step 1, for each file:
Call the function processing in the function calculation, carry on the face recognition and label. Save the marked file into OSS, and finally transfer the processed file.
Determine whether there are more files under the current OSS root path. If so, proceed to step 1. If not, the end process starts quickly.
Clone project to local
Git clone git@github.com:ChanDaoH/serverless-face-recognition.git replaces the YOUR_BUCKET_NAME in the template.yml file in the project directory with the OSS Bucket in Hangzhou area (which may not be Hangzhou area). OSS_ENDPOINT) ROSTemplateFormatVersion: '2015-09-01'Transform:' Aliyun::Serverless-2018-04-03'Resources: face-recognition: Type: 'Aliyun::Serverless::Service' Properties: Policies:-Version:' 1' Statement:-Effect: Allow Action:-'oss:ListObjects' -'oss:GetObject' -' oss:PutObject'-'oss:DeleteObject' -' fnf:*' Resource:'* 'listObjects: Type:' Aliyun::Serverless::Function' Properties: Handler: index.handler Runtime: python3 Timeout: 60 MemorySize: 128 CodeUri: functions/listobjects EnvironmentVariables: OSS_ENDPOINT: 'https://oss-cn-hangzhou-internal.aliyuncs.com' detectFaces: Type:' Aliyun::Serverless::Function' Properties: Handler: index.handler Runtime: python3 Timeout: 60 MemorySize: 512 CodeUri: functions/detectfaces EnvironmentVariables: OSS_ENDPOINT: 'https://oss -cn-hangzhou-internal.aliyuncs.com' timer: Type: 'Aliyun::Serverless::Function' Properties: Handler: index.handler Runtime: python3 Timeout: 60 MemorySize: 512 CodeUri: functions/timer Events: timeTrigger: Type: Timer Properties: CronExpression:' 0 *' Enable: true # replace YOUR_BUCKET_NAME to your oss bucket name Payload:'{"flowName": "oss-batch-process" "input": "{\" bucket\ ":\" YOUR_BUCKET_NAME\ ",\" prefix\ ":\"\ "} 'oss-batch-process: Type:' Aliyun::Serverless::Flow' Properties: Description: batch process flow DefinitionUri: flows/index.flow.yml Policies:-AliyunFCInvocationAccess
One-click deployment of functional computing and functional workflow resources to the cloud
Install the latest version of Fun to perform fun deploy effect verification in the root directory of the project and place the picture in the root directory of OSS Bucket
After waiting for a minute, the timing trigger triggers the function execution workflow.
After the workflow execution is complete, check the OSS Bucket
The image marked with human face is placed in the face-detection directory.
The processed videos are placed in the processed directory.
Summary
Through function calculation and function workflow, a regular batch image processing service is built for face recognition. Because the service uses the process of function workflow, it divides the task into multiple steps, and only needs to ensure that the function of each step can be completed within the limited time of function calculation (10 minutes).
Through the Fun tool, one-click deployment function calculation + function workflow, eliminating the steps of multi-platform operation.
Related reference
Function Computing function Workflow Aliyun Serverless VSCode plug-in Fun
Reference exampl
Serverless-face-recognitionoss-batch-process
"Alibaba Cloud Native focus on micro-services, Serverless, containers, Service Mesh and other technology areas, focus on cloud native popular technology trends, cloud native large-scale landing practice, to be the best understanding of cloud native developers of the technology circle."
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.