File tree Expand file tree Collapse file tree 4 files changed +71
-0
lines changed Expand file tree Collapse file tree 4 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
### Added
11
11
- Allow direct embedding vector upload together with dataset items. ` DatasetItem ` now has an additional parameter called ` embedding_info ` which can be used to directly upload embeddings when a dataset is uploaded.
12
+ - Added ` dataset.embedding_indexes ` property, which exposes information about every embedding index which belongs to the dataset.
12
13
13
14
14
15
## [ 0.16.6] ( https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.16.6 ) - 2023-11-01
Original file line number Diff line number Diff line change 52
52
EMBEDDING_VECTOR_KEY = "embedding_vector"
53
53
EMBEDDINGS_URL_KEY = "embeddings_urls"
54
54
EMBEDDING_DIMENSION_KEY = "embedding_dimension"
55
+ EMBEDDING_TYPE_KEY = "embedding_type"
55
56
ERRORS_KEY = "errors"
56
57
ERROR_CODES = "error_codes"
57
58
ERROR_ITEMS = "upload_errors"
73
74
INDEX_KEY = "index"
74
75
INDEX_ID_KEY = "index_id"
75
76
INDEX_CONTINUOUS_ENABLE_KEY = "enable"
77
+ INDEX_LEVEL_KEY = "index_level"
78
+ INDEX_TYPE_KEY = "index_type"
76
79
IOU_KEY = "iou"
77
80
ITEMS_KEY = "items"
78
81
ITEM_KEY = "item"
Original file line number Diff line number Diff line change 17
17
18
18
from nucleus .annotation_uploader import AnnotationUploader , PredictionUploader
19
19
from nucleus .async_job import AsyncJob , EmbeddingsExportJob
20
+ from nucleus .embedding_index import EmbeddingIndex
20
21
from nucleus .evaluation_match import EvaluationMatch
21
22
from nucleus .prediction import from_json as prediction_from_json
22
23
from nucleus .track import Track
@@ -194,6 +195,18 @@ def slices(self) -> List[Slice]:
194
195
)
195
196
return [Slice .from_request (info , self ._client ) for info in response ]
196
197
198
+ @property
199
+ def embedding_indexes (self ) -> List [EmbeddingIndex ]:
200
+ """Gets all the embedding indexes belonging to this Dataset."""
201
+ response = self ._client .make_request (
202
+ {}, f"dataset/{ self .id } /embeddingIndexes" , requests .get
203
+ )
204
+
205
+ return [
206
+ EmbeddingIndex .from_json (info )
207
+ for info in response ["embedding_indexes" ]
208
+ ]
209
+
197
210
def get_slices (
198
211
self ,
199
212
name : Optional [str ] = None ,
Original file line number Diff line number Diff line change
1
+ from dataclasses import dataclass
2
+ from enum import Enum
3
+
4
+ from nucleus .constants import (
5
+ EMBEDDING_DIMENSION_KEY ,
6
+ EMBEDDING_TYPE_KEY ,
7
+ ID_KEY ,
8
+ INDEX_LEVEL_KEY ,
9
+ INDEX_TYPE_KEY ,
10
+ STATUS_KEY ,
11
+ )
12
+
13
+
14
+ class IndexType (str , Enum ):
15
+ INTERNAL = "Internal"
16
+ CUSTOM = "Custom"
17
+
18
+
19
+ class IndexLevel (str , Enum ):
20
+ IMAGE = "Image"
21
+ OBJECT = "Object"
22
+
23
+
24
+ class IndexStatus (str , Enum ):
25
+ STARTED = "Started"
26
+ COMPLETED = "Completed"
27
+ ERRORED = "Errored"
28
+
29
+
30
+ @dataclass
31
+ class EmbeddingIndex :
32
+ """Represents an Embedding Index belonging to a Dataset.
33
+
34
+ Embedding Indexes contain generated embeddings for each item in the dataset,
35
+ and are used by the Autotag and the Similarity Search functionality.
36
+ """
37
+
38
+ id : str
39
+ status : IndexStatus
40
+ index_type : IndexType
41
+ index_level : IndexLevel
42
+ embedding_type : str
43
+ embedding_dimension : int
44
+
45
+ @classmethod
46
+ def from_json (cls , payload : dict ):
47
+ return cls (
48
+ id = payload [ID_KEY ],
49
+ status = payload [STATUS_KEY ],
50
+ index_type = payload [INDEX_TYPE_KEY ],
51
+ index_level = payload [INDEX_LEVEL_KEY ],
52
+ embedding_type = payload [EMBEDDING_TYPE_KEY ],
53
+ embedding_dimension = payload [EMBEDDING_DIMENSION_KEY ],
54
+ )
You can’t perform that action at this time.
0 commit comments