Spaces:
Sleeping
Sleeping
Gent (PG/R - Comp Sci & Elec Eng) commited on
Commit ·
a52e395
1
Parent(s): 161fda3
Add application file
Browse files
README.md
CHANGED
|
@@ -4,9 +4,163 @@ emoji: 💻
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
colorFrom: yellow
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.24.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Zero-shot Segmentation Demo
|
| 13 |
+
|
| 14 |
+
该项目包含 zero-shot segmentation的两种用例。并且提供本地运行版本,以及在线版本。
|
| 15 |
+
|
| 16 |
+
## Segmentation
|
| 17 |
+
|
| 18 |
+
## Instance Retrieval
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# 本地版本
|
| 22 |
+
|
| 23 |
+
```python demos/retrive.py --pretrained_weights checkpoint.pth --k_img imgs/sample5.JPEG --q_img imgs/mix.jpg```
|
| 24 |
+
|
| 25 |
+
```python main.py --img imgs/mix.jpg --pretrained_weights checkpoint.pth```
|
| 26 |
+
|
| 27 |
+
# 在线应用
|
| 28 |
+
# Image Matching API
|
| 29 |
+
## Overview
|
| 30 |
+
请注意,这个示例仅用于说明API接口的基本结构。实际实现时,您需要根据您的需求和技术选择来完成图像匹配和其他相关功能。
|
| 31 |
+
|
| 32 |
+
Person:
|
| 33 |
+
- 请设计详细的API接口文档并用markdown格式回答
|
| 34 |
+
|
| 35 |
+
ChatGPT:
|
| 36 |
+
- 以下是使用Markdown格式编写的详细API接口文档:
|
| 37 |
+
# Image Matching API
|
| 38 |
+
|
| 39 |
+
本API提供图像匹配服务,允许用户提交两张图片("key" 和 "query"),并根据用户在"query"图像上选择的区域,返回匹配的物体。
|
| 40 |
+
## 1. Submit
|
| 41 |
+
|
| 42 |
+
**Endpoint** : `/submit`
|
| 43 |
+
|
| 44 |
+
**Method** : `POST`
|
| 45 |
+
|
| 46 |
+
**Description** : 用户在前端上传两张图片("key" 和 "query"),服务器收到后将图片保存在云端并生成唯一的image id。返回image id。
|
| 47 |
+
### Request
|
| 48 |
+
- **Content-Type** : `multipart/form-data`ParameterTypeDescriptionkey_imageFile用户上传的"key"图片query_imageFile用户上传的"query"图片
|
| 49 |
+
### Response
|
| 50 |
+
- **Content-Type** : `application/json`ParameterTypeDescriptionkey_image_idString"key"图片的唯一IDquery_image_idString"query"图片的唯一ID
|
| 51 |
+
#### Example
|
| 52 |
+
|
| 53 |
+
**Request**
|
| 54 |
+
|
| 55 |
+
```http
|
| 56 |
+
|
| 57 |
+
POST /submit HTTP/1.1
|
| 58 |
+
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryyrV7KO0GIxCAQejs
|
| 59 |
+
|
| 60 |
+
------WebKitFormBoundaryyrV7KO0GIxCAQejs
|
| 61 |
+
Content-Disposition: form-data; name="key_image"; filename="key_image.jpg"
|
| 62 |
+
Content-Type: image/jpeg
|
| 63 |
+
|
| 64 |
+
(binary content)
|
| 65 |
+
------WebKitFormBoundaryyrV7KO0GIxCAQejs
|
| 66 |
+
Content-Disposition: form-data; name="query_image"; filename="query_image.jpg"
|
| 67 |
+
Content-Type: image/jpeg
|
| 68 |
+
|
| 69 |
+
(binary content)
|
| 70 |
+
------WebKitFormBoundaryyrV7KO0GIxCAQejs--
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
**Response**
|
| 76 |
+
|
| 77 |
+
```json
|
| 78 |
+
|
| 79 |
+
{
|
| 80 |
+
"key_image_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 81 |
+
"query_image_id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
| 82 |
+
}
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
## 3. Get Image
|
| 86 |
+
|
| 87 |
+
**Endpoint** : `/get_image`
|
| 88 |
+
|
| 89 |
+
**Method** : `GET`
|
| 90 |
+
|
| 91 |
+
**Description** : 前端根据image id获取对应的图片。
|
| 92 |
+
### RequestParameterTypeDescriptionimage_idString图片的唯一ID
|
| 93 |
+
### Response
|
| 94 |
+
- **Content-Type** : `image/jpeg`
|
| 95 |
+
#### Example
|
| 96 |
+
|
| 97 |
+
**Request**
|
| 98 |
+
|
| 99 |
+
```http
|
| 100 |
+
|
| 101 |
+
GET /get_image?image_id=550e8400-e29b-41d4-a716-446655440000 HTTP/1.1
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
**Response**
|
| 107 |
+
|
| 108 |
+
```http
|
| 109 |
+
|
| 110 |
+
HTTP/1.1 200 OK
|
| 111 |
+
Content-Type: image/jpeg
|
| 112 |
+
|
| 113 |
+
(binary content)
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
## 2. match
|
| 117 |
+
|
| 118 |
+
**Endpoint** : `/match`
|
| 119 |
+
|
| 120 |
+
**Method** : `POST`
|
| 121 |
+
|
| 122 |
+
**Description** : 用户选择"query"图像中的某个区域后,触发查询请求。前端发送"key" 和 "query"的image id,以及点击图片的坐标位置给服务器。服务器返回一个列表包含所有匹配的图片。
|
| 123 |
+
### Request
|
| 124 |
+
- **Content-Type** : `application/json`ParameterTypeDescriptionkey_image_idString"key"图片的唯一IDquery_image_idString"query"图片的唯一IDcoordsObject用户点击的坐标位置,包含"x"和"y"属性
|
| 125 |
+
### Response
|
| 126 |
+
- **Content-Type** : `application/json`ParameterTypeDescriptionimage_idString匹配图片的唯一IDurlString匹配图片的URL
|
| 127 |
+
#### Example
|
| 128 |
+
|
| 129 |
+
**Request**
|
| 130 |
+
|
| 131 |
+
```http
|
| 132 |
+
|
| 133 |
+
POST /select HTTP/1.1
|
| 134 |
+
Content-Type: application/json
|
| 135 |
+
|
| 136 |
+
{
|
| 137 |
+
"key_image_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 138 |
+
"query_image_id": "6ba7b810-9
|
| 139 |
+
}
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
## 2. segment
|
| 143 |
+
|
| 144 |
+
**Endpoint** : `/segment`
|
| 145 |
+
|
| 146 |
+
**Method** : `POST`
|
| 147 |
+
|
| 148 |
+
**Description** : 用户选择"query"图像中的某个区域后,触发查询请求。前端发送"query"的image id,以及点击图片的坐标位置给服务器。服务器返回一个列表包含所有匹配的图片。
|
| 149 |
+
### Request
|
| 150 |
+
- **Content-Type** : `application/json`ParameterTypeDescriptionkey_image_idString"key"图片的唯一IDquery_image_idString"query"图片的唯一IDcoordsObject用户点击的坐标位置,包含"x"和"y"属性
|
| 151 |
+
### Response
|
| 152 |
+
- **Content-Type** : `application/json`ParameterTypeDescriptionimage_idString匹配图片的唯一IDurlString匹配图片的URL
|
| 153 |
+
#### Example
|
| 154 |
+
|
| 155 |
+
**Request**
|
| 156 |
+
|
| 157 |
+
```http
|
| 158 |
+
|
| 159 |
+
POST /select HTTP/1.1
|
| 160 |
+
Content-Type: application/json
|
| 161 |
+
|
| 162 |
+
{
|
| 163 |
+
"key_image_id": "550e8400-e29b-41d4-a716-446655440000",
|
| 164 |
+
"query_image_id": "6ba7b810-9
|
| 165 |
+
}
|
| 166 |
+
```
|