-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.yaml
More file actions
661 lines (652 loc) · 27.1 KB
/
openapi.yaml
File metadata and controls
661 lines (652 loc) · 27.1 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
components:
schemas:
DatabaseEntry:
properties:
embedding:
items:
type: number
title: Embedding
type: array
metadata:
description: >-
The metadata is parsed as JSON to ensure its validity and regenerated
to possibly minimise it (e.g. removing unnecessary white spaces). The
regenerated JSON should at most 65535 characters long.
example:
language: ja
tags:
- text
title: Optional, arbitrary JSON object to attach to the image
type: object
url:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters. Optionally,\
\ additional metadata can be associated with the image as an arbitrary\
\ JSON object.\n\nAssumptions\n- Url follows pydantics' [HttpUrl](https://docs.pydantic.dev/usage/types/#urls):\
\ scheme http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over time.\n\
- Images are accessible from the server where Idios is hosted and do not\
\ require authentication.\n- Only JPEG images are supported\n- Images\
\ must have their\_dimensions\_above\_150 x 150 pixels, otherwise the\
\ API will return an error `IMAGE_SIZE_TOO_SMALL`\n- If one of the image\
\ dimension exceeds 1000 pixels, Idios will resize the image so that the\
\ maximum dimension is set to 1000 pixels and the original aspect ratio\
\ is kept.\n- Some image links may be permalinks from library or museum\
\ image collections or be hosted on IIIF servers that only accept certain\
\ request headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle the\
\ redirect silently and still use the original URL as the primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
required:
- url
- embedding
title: DatabaseEntry
type: object
HTTPValidationError:
properties:
detail:
items:
$ref: '#/components/schemas/ValidationError'
title: Detail
type: array
title: HTTPValidationError
type: object
ImageAndMetada:
properties:
metadata:
description: >-
The metadata is parsed as JSON to ensure its validity and regenerated
to possibly minimise it (e.g. removing unnecessary white spaces). The
regenerated JSON should at most 65535 characters long.
example:
language: ja
tags:
- text
title: Optional, arbitrary JSON object to attach to the image
type: object
url:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters. Optionally,\
\ additional metadata can be associated with the image as an arbitrary\
\ JSON object.\n\nAssumptions\n- Url follows pydantics' [HttpUrl](https://docs.pydantic.dev/usage/types/#urls):\
\ scheme http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over time.\n\
- Images are accessible from the server where Idios is hosted and do not\
\ require authentication.\n- Only JPEG images are supported\n- Images\
\ must have their\_dimensions\_above\_150 x 150 pixels, otherwise the\
\ API will return an error `IMAGE_SIZE_TOO_SMALL`\n- If one of the image\
\ dimension exceeds 1000 pixels, Idios will resize the image so that the\
\ maximum dimension is set to 1000 pixels and the original aspect ratio\
\ is kept.\n- Some image links may be permalinks from library or museum\
\ image collections or be hosted on IIIF servers that only accept certain\
\ request headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle the\
\ redirect silently and still use the original URL as the primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
required:
- url
title: ImageAndMetada
type: object
ImagePair:
properties:
other:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters. Optionally,\
\ additional metadata can be associated with the image as an arbitrary\
\ JSON object.\n\nAssumptions\n- Url follows pydantics' [HttpUrl](https://docs.pydantic.dev/usage/types/#urls):\
\ scheme http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over time.\n\
- Images are accessible from the server where Idios is hosted and do not\
\ require authentication.\n- Only JPEG images are supported\n- Images\
\ must have their\_dimensions\_above\_150 x 150 pixels, otherwise the\
\ API will return an error `IMAGE_SIZE_TOO_SMALL`\n- If one of the image\
\ dimension exceeds 1000 pixels, Idios will resize the image so that the\
\ maximum dimension is set to 1000 pixels and the original aspect ratio\
\ is kept.\n- Some image links may be permalinks from library or museum\
\ image collections or be hosted on IIIF servers that only accept certain\
\ request headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle the\
\ redirect silently and still use the original URL as the primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
url:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters. Optionally,\
\ additional metadata can be associated with the image as an arbitrary\
\ JSON object.\n\nAssumptions\n- Url follows pydantics' [HttpUrl](https://docs.pydantic.dev/usage/types/#urls):\
\ scheme http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over time.\n\
- Images are accessible from the server where Idios is hosted and do not\
\ require authentication.\n- Only JPEG images are supported\n- Images\
\ must have their\_dimensions\_above\_150 x 150 pixels, otherwise the\
\ API will return an error `IMAGE_SIZE_TOO_SMALL`\n- If one of the image\
\ dimension exceeds 1000 pixels, Idios will resize the image so that the\
\ maximum dimension is set to 1000 pixels and the original aspect ratio\
\ is kept.\n- Some image links may be permalinks from library or museum\
\ image collections or be hosted on IIIF servers that only accept certain\
\ request headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle the\
\ redirect silently and still use the original URL as the primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
required:
- url
- other
title: ImagePair
type: object
ModelName:
description: >-
The enumeration of supported models to extract embeddings from images
enum:
- vit_b32
title: ModelName
Pagination:
properties:
cursor:
description: >-
The cursor parameter is used for pagination purposes to allow clients
to retrieve a large set of results in smaller, more manageable chunks.
The cursor is a string that represents the position of the last item returned
in the previous API call.
When making a request to retrieve a set of images, the client can include
the cursor parameter in the request to specify where in the set of results
they want to start from. The API will return a subset of the results starting
after the url specified by the cursor.
title: Enumeration cursor
type: string
limit:
maximum: 16384.0
minimum: 1.0
title: Limit
type: integer
title: Pagination
type: object
SearchParameters:
properties:
limit:
default: 10
minimum: 1.0
title: Limit
type: integer
text:
title: Text
type: string
url:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters. Optionally,\
\ additional metadata can be associated with the image as an arbitrary\
\ JSON object.\n\nAssumptions\n- Url follows pydantics' [HttpUrl](https://docs.pydantic.dev/usage/types/#urls):\
\ scheme http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over time.\n\
- Images are accessible from the server where Idios is hosted and do not\
\ require authentication.\n- Only JPEG images are supported\n- Images\
\ must have their\_dimensions\_above\_150 x 150 pixels, otherwise the\
\ API will return an error `IMAGE_SIZE_TOO_SMALL`\n- If one of the image\
\ dimension exceeds 1000 pixels, Idios will resize the image so that the\
\ maximum dimension is set to 1000 pixels and the original aspect ratio\
\ is kept.\n- Some image links may be permalinks from library or museum\
\ image collections or be hosted on IIIF servers that only accept certain\
\ request headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle the\
\ redirect silently and still use the original URL as the primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
title: SearchParameters
type: object
SearchResult:
properties:
metadata:
description: >-
The metadata is parsed as JSON to ensure its validity and regenerated
to possibly minimise it (e.g. removing unnecessary white spaces). The
regenerated JSON should at most 65535 characters long.
example:
language: ja
tags:
- text
title: Optional, arbitrary JSON object to attach to the image
type: object
similarity:
$ref: '#/components/schemas/SimilarityScore'
url:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters. Optionally,\
\ additional metadata can be associated with the image as an arbitrary\
\ JSON object.\n\nAssumptions\n- Url follows pydantics' [HttpUrl](https://docs.pydantic.dev/usage/types/#urls):\
\ scheme http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over time.\n\
- Images are accessible from the server where Idios is hosted and do not\
\ require authentication.\n- Only JPEG images are supported\n- Images\
\ must have their\_dimensions\_above\_150 x 150 pixels, otherwise the\
\ API will return an error `IMAGE_SIZE_TOO_SMALL`\n- If one of the image\
\ dimension exceeds 1000 pixels, Idios will resize the image so that the\
\ maximum dimension is set to 1000 pixels and the original aspect ratio\
\ is kept.\n- Some image links may be permalinks from library or museum\
\ image collections or be hosted on IIIF servers that only accept certain\
\ request headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle the\
\ redirect silently and still use the original URL as the primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
required:
- url
- similarity
title: SearchResult
type: object
SearchResults:
items:
$ref: '#/components/schemas/SearchResult'
title: SearchResults
type: array
SimilarityScore:
description: Scores range from 0 to 100, with 100 being a perfect match.
maximum: 100.0
minimum: 0.0
title: SimilarityScore
type: number
SingleImage:
properties:
url:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters. Optionally,\
\ additional metadata can be associated with the image as an arbitrary\
\ JSON object.\n\nAssumptions\n- Url follows pydantics' [HttpUrl](https://docs.pydantic.dev/usage/types/#urls):\
\ scheme http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over time.\n\
- Images are accessible from the server where Idios is hosted and do not\
\ require authentication.\n- Only JPEG images are supported\n- Images\
\ must have their\_dimensions\_above\_150 x 150 pixels, otherwise the\
\ API will return an error `IMAGE_SIZE_TOO_SMALL`\n- If one of the image\
\ dimension exceeds 1000 pixels, Idios will resize the image so that the\
\ maximum dimension is set to 1000 pixels and the original aspect ratio\
\ is kept.\n- Some image links may be permalinks from library or museum\
\ image collections or be hosted on IIIF servers that only accept certain\
\ request headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle the\
\ redirect silently and still use the original URL as the primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
required:
- url
title: SingleImage
type: object
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
title: Location
type: array
msg:
title: Message
type: string
type:
title: Error Type
type: string
required:
- loc
- msg
- type
title: ValidationError
type: object
info:
description: >-
Idios is a reverse image search application with an HTTP API that allows you to
search for images that are visually similar.
It supports several embedding models. Images can be added to each of these models
separately. To do so, their embedding will be combuted and indexed in a milvus
collection. This will later allow to search, or compare other images in this collection.
Images of each model can also be deleted, listed and counted.
title: Idios
version: 0.1.0
openapi: 3.0.2
paths:
/models/{model_name}/add:
post:
operationId: upsert_image_models__model_name__add_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ImageAndMetada'
required: true
responses:
'204':
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: >-
Adds a new image embedding to the index.
Adding an existing url will replace the metadata with the provided one.
tags:
- model
/models/{model_name}/compare:
post:
operationId: compare_models__model_name__compare_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ImagePair'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/SimilarityScore'
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Compute the similarity score between two images
tags:
- model
/models/{model_name}/count:
get:
operationId: count_models__model_name__count_get
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
responses:
'200':
content:
application/json:
schema: {}
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Count the number of images in in a given index
tags:
- model
/models/{model_name}/dump:
post:
operationId: dump_models__model_name__dump_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Pagination'
default: {}
title: Pagination
responses:
'200':
content:
application/json:
schema:
items:
$ref: '#/components/schemas/DatabaseEntry'
title: Response Dump Models Model Name Dump Post
type: array
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: >-
Dump the urls, the embedding and the metadata of all images.
Use the pagination cursor to make sure that the enumeration reached the end.
tags:
- model
/models/{model_name}/remove:
post:
operationId: remove_image_models__model_name__remove_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SingleImage'
required: true
responses:
'204':
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Remove an image embedding from the index.
tags:
- model
/models/{model_name}/restore:
post:
operationId: restore_models__model_name__restore_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
items:
$ref: '#/components/schemas/DatabaseEntry'
title: Images
type: array
required: true
responses:
'204':
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: >-
Adds multiple image embeddings to the index.
Existing urls will have their metadata replaced with the provided one.
tags:
- model
/models/{model_name}/search:
post:
operationId: search_models__model_name__search_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SearchParameters'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/SearchResults'
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Search images with similar embeddings in the index
tags:
- model
/models/{model_name}/search_add:
post:
operationId: insert_image_models__model_name__search_add_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ImageAndMetada'
required: true
responses:
'204':
description: Successful Response
'409':
description: Image already inserted
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: >-
Adds a new image embedding to the index.
Adding an existing url will trigger a 409 HTTP error.
tags:
- model
/models/{model_name}/urls:
post:
operationId: list_images_models__model_name__urls_post
parameters:
- in: path
name: model_name
required: true
schema:
$ref: '#/components/schemas/ModelName'
requestBody:
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Pagination'
default: {}
title: Pagination
responses:
'200':
content:
application/json:
schema:
items:
description: "The url serves as the primary key in the Milvus collection.\
\ For consistancy, image URLs should not have escape characters.\
\ Optionally, additional metadata can be associated with the image\
\ as an arbitrary JSON object.\n\nAssumptions\n- Url follows pydantics'\
\ [HttpUrl](https://docs.pydantic.dev/usage/types/#urls): scheme\
\ http or https, TLD required, host required, max length 2083.\n\
- Images should have persitant URLs that will not change over\
\ time.\n- Images are accessible from the server where Idios is\
\ hosted and do not require authentication.\n- Only JPEG images\
\ are supported\n- Images must have their\_dimensions\_above\_\
150 x 150 pixels, otherwise the API will return an error `IMAGE_SIZE_TOO_SMALL`\n\
- If one of the image dimension exceeds 1000 pixels, Idios will\
\ resize the image so that the maximum dimension is set to 1000\
\ pixels and the original aspect ratio is kept.\n- Some image\
\ links may be permalinks from library or museum image collections\
\ or be hosted on IIIF servers that only accept certain request\
\ headers, additionally, the URL may return a 303 redirect to\
\ point you to the actual image. The API should be able to handle\
\ the redirect silently and still use the original URL as the\
\ primary key."
example: https://iiif.itatti.harvard.edu/iiif/2/yashiro!letters-jp!letter_001.pdf/full/full/0/default.jpg
title: URL of the image
type: string
title: Response List Images Models Model Name Urls Post
type: array
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: >-
List the urls of all images.
Use the pagination cursor to make sure that the enumeration reached the end.
tags:
- model
/ping:
get:
operationId: ping_ping_get
parameters:
- description: >-
Also send an RPC ping to check a round-trip with a worker via the job queue
in: query
name: rpc
required: false
schema:
default: false
description: >-
Also send an RPC ping to check a round-trip with a worker via the job
queue
title: Rpc
type: boolean
responses:
'200':
content:
application/json:
schema:
enum:
- pong
title: Response Ping Ping Get
type: string
description: Successful Response
'422':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
description: Validation Error
summary: Check for the health of the server.
tags:
- misc