This topic describes how to use the PASE plug-in of ApsaraDB RDS for PostgreSQL to recognize images and faces, retrieve images, and spot audience members at low costs but high efficiency.
Prerequisites
Background information
Comparison between Solution 1 and Solution 2
Comparison item | Solution 1
(MySQL) |
Solution 2
(PostgreSQL) |
Competitive advantage of Solution 2 over Solution 1 |
---|---|---|---|
Single-query response speed | 61.45 seconds | 0.0025 seconds | 2,457,900% |
Concurrent queries per second | 0.055330 | 1,056 | 1,908,449% |
Challenges
Common relational databases such as MySQL do not support vector-based retrieval. They must traverse all data and return the obtained results to the application layer. The application layer then computes the results to respond to queries. The queries are slow and consume a large number of network bandwidth resources. Even if such databases can be optimized to support operators used for vector-based retrieval, they still need to traverse all data and cannot process highly concurrent queries, because they do not support vector indexing.
If the application layer implements image vector computing, it must load all the data from your database, which is slow. In addition, the application layer cannot load new data from updated images in real time, recognize images, or filter images based on combinations of criteria.
Scenarios
ApsaraDB RDS for PostgreSQL is an optimal solution that is designed to precisely search for similar images at a high speed based on a specific image and a combination of criteria.
- In the smart building sector, ApsaraDB RDS for PostgreSQL scans the faces of employees who enter a building. If it recognizes an employee, it automatically clocks that employee in and sets the elevator to stop at the floor where that employee works.
- In the smart hotel sector, ApsaraDB RDS for PostgreSQL scans the faces of customers who enter a hotel. If it recognizes a customer, it automatically checks that customer in and offers exclusive services to that customer based on their customer membership level.
- In the e-commerce sector, ApsaraDB RDS for PostgreSQL searches for similar items based on the image you specify.
- In the education sector, ApsaraDB RDS for PostgreSQL scans the faces of students to record their behavior in class (for example, whether they are napping, distracted, fidgeting, or raising hands).
- In the public transportation sector, ApsaraDB RDS for MySQL recognizes drivers who violate transportation regulations.
- In the new retail sector, ApsaraDB RDS for PostgreSQL recognizes the faces of customers who enter a retail shop. If it recognizes a customer as a member registered with the retail shop, it sends reminders of new arrivals, provides guidance, and offers exclusive services to that customer.
- In the public transportation sector, ApsaraDB RDS for PostgreSQL enables face scan payments.
- In the gaming sector, ApsaraDB RDS for PostgreSQL facilitates virtual reality-related games.
Before you begin
Solution 1
- Characteristics
- Your database only stores image vectors but does not compute them.
- The application layer computes image vectors.
- Demerits
- Your database cannot index or filter vectors.
- The application layer must load all the data from your database, which is slow. In addition, the application layer cannot load new data from updated images in real time.
- Your database cannot recognize images or filter images based on combinations of criteria. Images can only be recognized and filtered at the application layer. However, the application layer cannot process highly concurrent queries due to the large number of network transmission records.
Procedure
Solution 2
- Characteristics
- ApsaraDB RDS for PostgreSQL stores the values of image feature vectors.
- The PASE plug-in of ApsaraDB RDS for PostgreSQL creates indexes for image feature vectors.
- After you specify an image feature vector at the application layer, the application layer retrieves the images similar to the image feature vector from ApsaraDB RDS for PostgreSQL based on the index of the image feature vector. In addition, the application layer returns the distances among vectors and sorts the retrieved images based on these distances.
- If you specify more than one filter criterion, ApsaraDB RDS for PostgreSQL combines the filter criteria before it filters indexes.
- Merits
- ApsaraDB RDS for PostgreSQL supports vector indexing, which expedites image searches.
- ApsaraDB RDS for PostgreSQL filters indexes based on a combination of images and other attribute criteria to converge result sets, increase query speeds, and decrease the volume of data transmitted. A single query can be completed in milliseconds.
- You can add read-only instances to further increase the overall query throughput.
Procedure
Summary
ApsaraDB RDS for PostgreSQL uses the PASE plug-in to retrieve high-dimensional vectors based on indexes. This enables ApsaraDB RDS for PostgreSQL to respond to a single query for similar images in milliseconds. PASE can also be used in digital businesses such as searches for profiles and audience members. PASE searches for vectors and filters them based on a combination of criteria simultaneously in your database to expedite queries.
ApsaraDB RDS for PostgreSQL is ideal for businesses with needs for highly concurrent queries. Such businesses include the Internet, new retail, public transportation, smart buildings, education, gaming, medical care, social networking, public security, and airports.
Video tutorials
Multidimensional vector similarity search for image recognition