Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build an image search service function with Vearch

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to use Vearch to build an image search service function". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

What is image search?

In ancient times, people's ability to deal with pictures was very limited. Image search may be a text search of the file name, summary, or length, width, or path of a picture. In modern Bart society, people prefer to use graph search graph to replace this statement. Basically, all major search engines support this kind of search. The figure below is as follows

What is Vearch?

Vearch is a distributed vector search system, which can be used to calculate vector similarity or be used in the field of machine learning. It supports billion-second vector indexing, such as image recognition, video recognition or natural language processing. This system is based on Faiss and provides fast vector retrieval function. Providing Restful API similar to Elasticsearch can easily manage and query the data and table structure. The code is here: code Cloud Warehouse

Hand-in-hand teaching

Environmental requirements. Computer + docker + python3

Install docker if you don't know how to install Baidu, this is beyond the scope of this article, if you learn, you will not install docker, click on the upper right corner to close. (upper left corner of Linux,mac), for our convenience, we don't use virtual paths instead. Use a real path to describe the installation process. Readers can modify the work path according to their own situation without making any more statements.

Compile & start the Vearch# creation directory mkdir-p / home/vearchcd / home/vearch [root@localhost vearch] # pwd/home/vearch# download the source code [root@localhost vearch] # git clone https://github.com/vearch/vearch.gitCloning into 'vearch'...remote: Enumerating objects: 50, done.remote: Counting objects: 100% (50x50), done.remote: Compressing objects: 100% (36into 36), done.remote: Total 3791 (delta 22), reused 19 (delta 7) Pack-reused 3741Receiving objects: 100% (3791 KiB/s 3791), 11.73 MiB | 342.00 KiB/s, done.Resolving deltas: 100% (731 KiB/s) Done. [root@localhost vearch] # # compile Vearchcd vearch/cloud/docker pull ansj/vearch_env./compile.sh# to create a runnable image of vearch. / build.sh# copy exaple configuration file come here as a stand-alone configuration cat.. / config/config.toml.example > config.toml# launch Vearchdocker run-p 8817pur8817-p 9001Vearchcd vearch/cloud/docker pull ansj/vearch_env./compile.sh# 9001-v $PWD/config.toml:/vearch/config.toml vearch all

If the startup is successful, you will see the following message

2019-10-15 04:58:13 startup.go:63: [INFO] start server by version: [0.1] commitID: [3a0ed89b690ea2cf566a45fc5681b0a1ca170726] 2019-10-15 04:58:13 startup.go:72: [INFO] The Config File Is: / vearch/config.toml2019/10/15 04:58:13 startup.go:76: [INFO] The configuration content is: .

If you open a browser and visit http://127.0.0.1:8817/, you can see the following figure that shows the proper startup

Launch the image plug-in cd / home/vearch/vearch/pluginsudo. / bin/run.sh image

If the startup is successful, you will see the following message

Load model success

Create a library table

And let us build a database table, named test

Curl-XPOST-H "content-type:application/json"-d'{"db": true, "method": 0, "columns": {"imageurl": {"type": "keyword"}, "boundingbox": {"type": "keyword"} "label": {"type": "keyword"}, "feature": {"type": "vector", "filed": "imageurl", "model_id": "vgg16", "dimension": 512} 'http://127.0.0.1:4101/test/test/_create data insertion

If the database table is ready, you should store the data. Take demo as an example.

Curl-XPOST-H "content-type:application/json"-d'{"imageurl": "http://www.gming.org/uploadfile/2015/0914/20150914104444833.jpg"," detection ": false," label ":" coat "} 'http://127.0.0.1:4101/test/test/_insert

As you can see below, the work is accomplished.

{"db": "test", "space": "test", "ids": [{"AW3tYgdsAkKsEQACQOnu": "successful"}], "successful": 1} Image search curl-XPOST-H "content-type:application/json"-d'{"imageurl": "http://www.gming.org/uploadfile/2015/0914/20150914104444833.jpg"," size ": 5} 'http://127.0.0.1:4101/test/test/_search

As you can see below, the work is accomplished.

{"took": 63, "timed_out": false, "_ shards": {"total": 1, "failed": 0, "successful": 1}, "hits": {"total": 1, "max_score": 0.9999998807907104, "hits": [{"_ index": "test", "_ type": "test", "_ id": "AW3xfmlQAkKsEQACMRjf", "_ score": 0.99998807907104 "_ extra": {"vector_result": [{"field": "feature", "source": "http://www.gming.org/uploadfile/2015/0914/20150914104444833.jpg"," score ": 0.9999998807907104}]}," _ version ": 1," _ source ": {" boundingbox ":", "imageurl": "http://www.gming.org/uploadfile/2015/0914/20150914104444833.jpg"," So much for "label": "coat"}% "how to build an image search service with Vearch". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report