Skip to content

Commit a040aee

Browse files
committed
Refactor vit and yolo func
Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Read csv with id Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Update set parallel Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Add vec normalize Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Add getting started Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Add workflow png Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Update content of notebook Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Update content of notebook Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Add README Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Add python file Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Update load.py Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Add advanced notebook Signed-off-by: shiyu22 <shiyu.chen@zilliz.com> Add advanced notebook Signed-off-by: shiyu22 <shiyu.chen@zilliz.com>
1 parent 6f27272 commit a040aee

7 files changed

Lines changed: 2041 additions & 182 deletions

File tree

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,53 @@
11
# Reverse Image Search
22

3-
- Run notebook with [reverse_image_search.ipynb](./reverse_image_search.ipynb).
4-
5-
- Start server with fastapi.
6-
7-
```bash
8-
$ python api.py
9-
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
10-
```
11-
12-
Test the server:
13-
14-
> Before running it, make sure you have created the `collection_name` collection in **api.py**. And the following example already has 1000
15-
> entities in Milvus' 'reverse_image_search' collection.
16-
17-
```bash
18-
# upload an image and search
19-
$ curl -X POST "http://0.0.0.0:8000/search" --data-binary @extracted_test/n01443537/n01443537_3883.JPEG -H 'Content-Type: image/jpeg'
20-
{"path":"/Users/chenshiyu/workspace/data/pic/1.jpg","result":[83682058,9605572,67200803,69780733,45421918,99335156,2345006,5632544,5632544,
21-
28616422]}%
22-
# upload an image and insert
23-
$ curl -X POST "http://0.0.0.0:8000/insert" --data-binary @extracted_test/n01443537/n01443537_3883.JPEG -H 'Content-Type: image/jpeg'
24-
{"mr":"(insert count: 1, delete count: 0, upsert count: 0, timestamp: 432699123898515457)"}
25-
# count the collection
26-
$ curl -X POST "http://0.0.0.0:8000/count"
27-
1001
28-
```
3+
This image search example mainly consists of two notebooks, and two python files about "how to load large images" and "start an online service".
4+
5+
6+
7+
I hope you can learn the basic operations of towhee and milvus through the [getting started notebook](./getting_started.ipynb). And the [advanced notebook](advanced.ipynb) will tell you how to choose the model and how to deploy the service.
8+
9+
[load.py](./load.py) is used to import your large-scale image data, and [server.py](./server.py) will start a FastAPI-based service.
10+
11+
## Learn from Notebook
12+
13+
- [Getting started](getting_started.ipynb)
14+
15+
In this notebook you will get the prerequisites (data, install milvus and towhee), how to complete a simple image system search and visualize results, and how to report accuracy and performance metrics.
16+
17+
- [Advanced](./advanced.ipynb)
18+
19+
In this notebook you will learn how to use various models and evaluate recall metrics, also providing object detection method. There is also about how to improve system performance and stability, and finally show you how to start the FastAPI service.
20+
21+
## Load Large-scale Image Data
22+
23+
I think you already know from previous notebooks that a very important step in reverse image search is loading the data. If you have large-scale data, you can try running the `set_parallel` and `exception_safe` methods of [load.py](./load.py), which make the import process faster and safer.
24+
25+
> You can load your own data in this script.
26+
27+
```bash
28+
$ python load.py
29+
Collection number: 1000
30+
```
31+
32+
## Deploy with FastAPI
33+
34+
After the data is loaded, you can start the search service for reverse image search, and also support inserting data services.
35+
36+
```bash
37+
$ python server.py
38+
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
39+
```
40+
41+
Next you can test the service with the following command.
42+
43+
```bash
44+
# upload an image and search
45+
$ curl -X POST "http://0.0.0.0:8000/search" --data-binary @extracted_test/n01443537/n01443537_3883.JPEG -H 'Content-Type: image/jpeg'
46+
47+
# upload an image and insert
48+
$ curl -X POST "http://0.0.0.0:8000/insert" --data-binary @extracted_test/n01443537/n01443537_3883.JPEG -H 'Content-Type: image/jpeg'
49+
50+
# count the collection
51+
$ curl -X POST "http://0.0.0.0:8000/count"
52+
1001
53+
```

0 commit comments

Comments
 (0)