File size: 4,457 Bytes
0ea2df4
 
 
 
 
 
a52e395
0ea2df4
 
 
 
a52e395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
---
title: SimilarityThresholding
emoji: 💻
colorFrom: yellow
colorTo: yellow
sdk: gradio
sdk_version: 3.24.1
app_file: app.py
pinned: false
---

# Zero-shot Segmentation Demo

该项目包含 zero-shot segmentation的两种用例。并且提供本地运行版本,以及在线版本。

## Segmentation

## Instance Retrieval


# 本地版本

```python demos/retrive.py   --pretrained_weights checkpoint.pth  --k_img imgs/sample5.JPEG --q_img imgs/mix.jpg```

```python main.py --img imgs/mix.jpg  --pretrained_weights checkpoint.pth```

# 在线应用
# Image Matching API
## Overview
请注意,这个示例仅用于说明API接口的基本结构。实际实现时,您需要根据您的需求和技术选择来完成图像匹配和其他相关功能。

Person: 
- 请设计详细的API接口文档并用markdown格式回答

ChatGPT: 
- 以下是使用Markdown格式编写的详细API接口文档:
# Image Matching API

本API提供图像匹配服务,允许用户提交两张图片("key" 和 "query"),并根据用户在"query"图像上选择的区域,返回匹配的物体。
## 1. Submit

**Endpoint** : `/submit`

**Method** : `POST`

**Description** : 用户在前端上传两张图片("key" 和 "query"),服务器收到后将图片保存在云端并生成唯一的image id。返回image id。
### Request 
- **Content-Type** : `multipart/form-data`ParameterTypeDescriptionkey_imageFile用户上传的"key"图片query_imageFile用户上传的"query"图片
### Response 
- **Content-Type** : `application/json`ParameterTypeDescriptionkey_image_idString"key"图片的唯一IDquery_image_idString"query"图片的唯一ID
#### Example

**Request** 

```http

POST /submit HTTP/1.1
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryyrV7KO0GIxCAQejs

------WebKitFormBoundaryyrV7KO0GIxCAQejs
Content-Disposition: form-data; name="key_image"; filename="key_image.jpg"
Content-Type: image/jpeg

(binary content)
------WebKitFormBoundaryyrV7KO0GIxCAQejs
Content-Disposition: form-data; name="query_image"; filename="query_image.jpg"
Content-Type: image/jpeg

(binary content)
------WebKitFormBoundaryyrV7KO0GIxCAQejs--
```



**Response** 

```json

{
  "key_image_id": "550e8400-e29b-41d4-a716-446655440000",
  "query_image_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
}
```

## 3. Get Image

**Endpoint** : `/get_image`

**Method** : `GET`

**Description** : 前端根据image id获取对应的图片。
### RequestParameterTypeDescriptionimage_idString图片的唯一ID
### Response 
- **Content-Type** : `image/jpeg`
#### Example

**Request** 

```http

GET /get_image?image_id=550e8400-e29b-41d4-a716-446655440000 HTTP/1.1
```



**Response** 

```http

HTTP/1.1 200 OK
Content-Type: image/jpeg

(binary content)
```

## 2. match

**Endpoint** : `/match`

**Method** : `POST`

**Description** : 用户选择"query"图像中的某个区域后,触发查询请求。前端发送"key" 和 "query"的image id,以及点击图片的坐标位置给服务器。服务器返回一个列表包含所有匹配的图片。
### Request 
- **Content-Type** : `application/json`ParameterTypeDescriptionkey_image_idString"key"图片的唯一IDquery_image_idString"query"图片的唯一IDcoordsObject用户点击的坐标位置,包含"x"和"y"属性
### Response 
- **Content-Type** : `application/json`ParameterTypeDescriptionimage_idString匹配图片的唯一IDurlString匹配图片的URL
#### Example

**Request** 

```http

POST /select HTTP/1.1
Content-Type: application/json

{
  "key_image_id": "550e8400-e29b-41d4-a716-446655440000",
  "query_image_id": "6ba7b810-9
}
```

## 2. segment

**Endpoint** : `/segment`

**Method** : `POST`

**Description** : 用户选择"query"图像中的某个区域后,触发查询请求。前端发送"query"的image id,以及点击图片的坐标位置给服务器。服务器返回一个列表包含所有匹配的图片。
### Request 
- **Content-Type** : `application/json`ParameterTypeDescriptionkey_image_idString"key"图片的唯一IDquery_image_idString"query"图片的唯一IDcoordsObject用户点击的坐标位置,包含"x"和"y"属性
### Response 
- **Content-Type** : `application/json`ParameterTypeDescriptionimage_idString匹配图片的唯一IDurlString匹配图片的URL
#### Example

**Request** 

```http

POST /select HTTP/1.1
Content-Type: application/json

{
  "key_image_id": "550e8400-e29b-41d4-a716-446655440000",
  "query_image_id": "6ba7b810-9
}
```