layernext-beta 2.2.1b6__tar.gz → 2.2.1b8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {layernext-beta-2.2.1b6/layernext_beta.egg-info → layernext-beta-2.2.1b8}/PKG-INFO +1 -6
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/__init__.py +276 -19
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/automatic_analysis/__init__.py +95 -25
- layernext-beta-2.2.1b8/layernext/automatic_analysis/automatic_analysis.py +84 -0
- layernext-beta-2.2.1b8/layernext/automatic_analysis/automatic_analysis_interface.py +155 -0
- layernext-beta-2.2.1b8/layernext/automatic_analysis/status_check_autoannotate_project.py +376 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/automatic_analysis/support.py +37 -1
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/__init__.py +84 -4
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/constants.py +11 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/datalakeinterface.py +154 -11
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/storage_upload.py +3 -1
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8/layernext_beta.egg-info}/PKG-INFO +1 -6
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/SOURCES.txt +1 -3
- layernext-beta-2.2.1b6/layernext/automatic_analysis/automatic_analysis_interface.py +0 -157
- layernext-beta-2.2.1b6/layernext/automatic_analysis/status_check_autoannotate_project.py +0 -186
- layernext-beta-2.2.1b6/layernext/automatic_analysis/status_check_autotag_collection.py +0 -183
- layernext-beta-2.2.1b6/layernext/automatic_analysis/status_check_autotag_population.py +0 -136
- layernext-beta-2.2.1b6/layernext/automatic_analysis/status_check_embedding_collection.py +0 -164
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/LICENSE +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/README.md +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/annotation.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/aws_s3_client.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/azure_client.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/dataset.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/file_trash.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/file_upload.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/gcs_client.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/ground_truth.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/keys.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/label.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/logger.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/metadata.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/model_run.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/query.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/storage_client.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/datalake/storage_interface.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/dataset/__init__.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/dataset/dataset.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/dataset/datasetinterface.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/dataset/logger.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/dataset/sync.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/studio/__init__.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/studio/logger.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/studio/project.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext/studio/studiointerface.py +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/dependency_links.txt +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/requires.txt +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/layernext_beta.egg-info/top_level.txt +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/setup.cfg +0 -0
- {layernext-beta-2.2.1b6 → layernext-beta-2.2.1b8}/setup.py +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: layernext-beta
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1b8
|
|
4
4
|
Summary: LayerNext Python SDK
|
|
5
|
-
Home-page: UNKNOWN
|
|
6
5
|
Author: LayerNext
|
|
7
6
|
Author-email: <support@layernext.ai>
|
|
8
|
-
License: UNKNOWN
|
|
9
7
|
Keywords: python,datalake,datasetsync,ai,annotation,layernext,layernext,machine learning
|
|
10
|
-
Platform: UNKNOWN
|
|
11
8
|
Classifier: Development Status :: 1 - Planning
|
|
12
9
|
Classifier: Intended Audience :: Developers
|
|
13
10
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -40,5 +37,3 @@ url = 'https://api.xxxx.layernext.ai'
|
|
|
40
37
|
client = layernext.LayerNextClient(api_key, secret, url)
|
|
41
38
|
|
|
42
39
|
```
|
|
43
|
-
|
|
44
|
-
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import base64
|
|
2
|
+
import datetime
|
|
3
|
+
|
|
2
4
|
from typing import List, Union, Dict
|
|
3
5
|
from layernext import datalake, dataset, studio, automatic_analysis
|
|
4
|
-
from layernext.datalake.constants import (AnnotationUploadType, ItemType,
|
|
6
|
+
from layernext.datalake.constants import (AnnotationUploadType, ItemType, JobStatus, JobType,
|
|
5
7
|
MediaType, ObjectType, SortField,
|
|
6
8
|
SortFieldName, SortOrder, AnnotationShapeType)
|
|
7
9
|
from deprecated import deprecated
|
|
8
10
|
|
|
9
|
-
__version__ = '2.2.
|
|
11
|
+
__version__ = '2.2.1b8'
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
class LayerNextClient:
|
|
@@ -423,6 +425,15 @@ class LayerNextClient:
|
|
|
423
425
|
self.encoded_key_secret, self.layernext_url)
|
|
424
426
|
|
|
425
427
|
return _datalake_client.get_collection_details(collection_id, fields_filter)
|
|
428
|
+
|
|
429
|
+
"""
|
|
430
|
+
Use to get system image, video, other count
|
|
431
|
+
"""
|
|
432
|
+
def get_system_stat_count(self):
|
|
433
|
+
_datalake_client = datalake.DatalakeClient(
|
|
434
|
+
self.encoded_key_secret, self.layernext_url)
|
|
435
|
+
|
|
436
|
+
return _datalake_client.get_system_stat_count()
|
|
426
437
|
|
|
427
438
|
"""
|
|
428
439
|
get collection id by name
|
|
@@ -2030,14 +2041,27 @@ class LayerNextClient:
|
|
|
2030
2041
|
self,
|
|
2031
2042
|
collection_id,
|
|
2032
2043
|
model_id='default',
|
|
2033
|
-
input_resolution=(
|
|
2044
|
+
input_resolution=(480,480),
|
|
2034
2045
|
confidence_threshold=0.5
|
|
2035
2046
|
):
|
|
2036
2047
|
|
|
2048
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2049
|
+
job_name = f"Auto-tagging-generate-{model_id}"
|
|
2050
|
+
|
|
2051
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_AUTO_TAGGING.value, 0, JobStatus.QUEUED.value)
|
|
2052
|
+
|
|
2053
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2054
|
+
job_id = res_obj["jobId"]
|
|
2055
|
+
else:
|
|
2056
|
+
print("Error occurred while create job")
|
|
2057
|
+
raise Exception("Error occurred while create job")
|
|
2058
|
+
|
|
2037
2059
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2038
2060
|
self.encoded_key_secret, self.layernext_url)
|
|
2039
|
-
_automatic_analysis_client.model_tag_collection(
|
|
2040
|
-
collection_id, model_id, input_resolution,confidence_threshold)
|
|
2061
|
+
res = _automatic_analysis_client.model_tag_collection(
|
|
2062
|
+
collection_id, model_id, input_resolution,confidence_threshold,session_id,job_id,job_name)
|
|
2063
|
+
|
|
2064
|
+
return res
|
|
2041
2065
|
|
|
2042
2066
|
|
|
2043
2067
|
"""
|
|
@@ -2055,10 +2079,23 @@ class LayerNextClient:
|
|
|
2055
2079
|
confidence_threshold=0.5
|
|
2056
2080
|
):
|
|
2057
2081
|
|
|
2082
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2083
|
+
job_name = f"Auto-tagging-generate-{model_id}"
|
|
2084
|
+
|
|
2085
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_AUTO_TAGGING.value, 0, JobStatus.QUEUED.value)
|
|
2086
|
+
|
|
2087
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2088
|
+
job_id = res_obj["jobId"]
|
|
2089
|
+
else:
|
|
2090
|
+
print("Error occurred while create job")
|
|
2091
|
+
raise Exception("Error occurred while create job")
|
|
2092
|
+
|
|
2058
2093
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2059
2094
|
self.encoded_key_secret, self.layernext_url)
|
|
2060
|
-
_automatic_analysis_client.model_tag_population(
|
|
2061
|
-
item_type, model_id, input_resolution, confidence_threshold)
|
|
2095
|
+
res = _automatic_analysis_client.model_tag_population(
|
|
2096
|
+
item_type, model_id, input_resolution, confidence_threshold,session_id,job_id,job_name)
|
|
2097
|
+
|
|
2098
|
+
return res
|
|
2062
2099
|
|
|
2063
2100
|
|
|
2064
2101
|
"""
|
|
@@ -2068,22 +2105,40 @@ class LayerNextClient:
|
|
|
2068
2105
|
@param annotation_type : bounding box annotation or polygon segment annotation
|
|
2069
2106
|
@param model_id : id/name of the model which is registered in the datalake
|
|
2070
2107
|
@param confidence_threshold : confidence score to consider which objects/segments to consider for the proccedings
|
|
2108
|
+
@auto_annotation_operation : Operation to do , sam-text, sam-img-encoding
|
|
2071
2109
|
"""
|
|
2072
2110
|
def auto_annotate_project(
|
|
2073
2111
|
self,
|
|
2074
2112
|
project_id,
|
|
2075
|
-
prompt,
|
|
2113
|
+
# prompt=[],
|
|
2076
2114
|
annotation_type='segment',
|
|
2077
2115
|
model_id='default',
|
|
2078
|
-
confidence_threshold=0.5
|
|
2116
|
+
# confidence_threshold=0.5,
|
|
2117
|
+
# auto_annotation_operation='sam-text'
|
|
2118
|
+
**kwargs
|
|
2079
2119
|
):
|
|
2080
2120
|
|
|
2081
2121
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2082
2122
|
self.encoded_key_secret, self.layernext_url)
|
|
2123
|
+
# _automatic_analysis_client.model_annotate_collection(
|
|
2124
|
+
# project_id, model_id, prompt, annotation_type, confidence_threshold, auto_annotation_operation)
|
|
2083
2125
|
_automatic_analysis_client.model_annotate_collection(
|
|
2084
|
-
project_id, model_id,
|
|
2085
|
-
|
|
2086
|
-
|
|
2126
|
+
project_id, model_id, annotation_type, **kwargs)
|
|
2127
|
+
|
|
2128
|
+
def prompt_inference(
|
|
2129
|
+
self,
|
|
2130
|
+
name,
|
|
2131
|
+
shape,
|
|
2132
|
+
**kwargs
|
|
2133
|
+
):
|
|
2134
|
+
|
|
2135
|
+
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2136
|
+
self.encoded_key_secret, self.layernext_url)
|
|
2137
|
+
|
|
2138
|
+
_automatic_analysis_client.prompt_infer_image(
|
|
2139
|
+
name,
|
|
2140
|
+
shape, **kwargs)
|
|
2141
|
+
|
|
2087
2142
|
"""
|
|
2088
2143
|
generate embedding for a given collection (image) and upload the embeddings to the vector database
|
|
2089
2144
|
@param collection_id: id of the image.
|
|
@@ -2092,15 +2147,55 @@ class LayerNextClient:
|
|
|
2092
2147
|
def generate_embeddings_for_collection(
|
|
2093
2148
|
self,
|
|
2094
2149
|
collection_id,
|
|
2095
|
-
model_id='default'
|
|
2150
|
+
model_id='default',
|
|
2151
|
+
query="",
|
|
2152
|
+
filters={}
|
|
2096
2153
|
):
|
|
2097
2154
|
|
|
2155
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2156
|
+
job_name = f"Embedding-generate-{model_id}"
|
|
2157
|
+
|
|
2158
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_EMBEDDING.value, 0, JobStatus.QUEUED.value)
|
|
2159
|
+
|
|
2160
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2161
|
+
job_id = res_obj["jobId"]
|
|
2162
|
+
else:
|
|
2163
|
+
print("Error occurred while create job")
|
|
2164
|
+
raise Exception("Error occurred while create job")
|
|
2165
|
+
|
|
2098
2166
|
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2099
2167
|
self.encoded_key_secret, self.layernext_url)
|
|
2100
|
-
_automatic_analysis_client.embedding_model_inference_collection(
|
|
2101
|
-
collection_id, model_id)
|
|
2168
|
+
res = _automatic_analysis_client.embedding_model_inference_collection(
|
|
2169
|
+
collection_id, model_id, query, filters, session_id,job_id, job_name)
|
|
2170
|
+
return res
|
|
2102
2171
|
|
|
2103
2172
|
|
|
2173
|
+
def generate_embeddings_to_metalake(
|
|
2174
|
+
self,
|
|
2175
|
+
item_type='image',
|
|
2176
|
+
model_id='default',
|
|
2177
|
+
query="",
|
|
2178
|
+
filters={}
|
|
2179
|
+
):
|
|
2180
|
+
|
|
2181
|
+
session_id = str(datetime.datetime.now().timestamp())
|
|
2182
|
+
job_name = f"Embedding-generate-{model_id}"
|
|
2183
|
+
|
|
2184
|
+
res_obj = self.create_or_update_job(session_id, job_name, JobType.GENERATE_EMBEDDING.value, 0, JobStatus.QUEUED.value)
|
|
2185
|
+
|
|
2186
|
+
if("success" in res_obj and res_obj["success"]==True) and res_obj["jobId"] is not None:
|
|
2187
|
+
job_id = res_obj["jobId"]
|
|
2188
|
+
else:
|
|
2189
|
+
print("Error occurred while create job")
|
|
2190
|
+
raise Exception("Error occurred while create job")
|
|
2191
|
+
|
|
2192
|
+
_automatic_analysis_client = automatic_analysis.AutomaticAnalysisClient(
|
|
2193
|
+
self.encoded_key_secret, self.layernext_url)
|
|
2194
|
+
res = _automatic_analysis_client.model_embedding_population(
|
|
2195
|
+
item_type, model_id, query, filters, session_id,job_id, job_name)
|
|
2196
|
+
|
|
2197
|
+
return res
|
|
2198
|
+
|
|
2104
2199
|
"""
|
|
2105
2200
|
get item list from data lake
|
|
2106
2201
|
@item_type: "image", "video", "other", "image_collection", "video_collection", "other_collection", "dataset"
|
|
@@ -2149,6 +2244,44 @@ class LayerNextClient:
|
|
|
2149
2244
|
page_size,
|
|
2150
2245
|
sort_filter
|
|
2151
2246
|
)
|
|
2247
|
+
|
|
2248
|
+
"""
|
|
2249
|
+
get item count from metalake
|
|
2250
|
+
@item_type: "image", "video", "other", "image_collection", "video_collection", "other_collection", "dataset"
|
|
2251
|
+
@query: metalake query
|
|
2252
|
+
@filter: {date: {fromDate: "", toDate: ""}, "annotation_types": ["human", "raw", "machine"]}
|
|
2253
|
+
"""
|
|
2254
|
+
def get_item_count_from_metalake(
|
|
2255
|
+
self,
|
|
2256
|
+
item_type,
|
|
2257
|
+
query: str = "",
|
|
2258
|
+
filter={},
|
|
2259
|
+
):
|
|
2260
|
+
|
|
2261
|
+
_datalake_client = datalake.DatalakeClient(
|
|
2262
|
+
self.encoded_key_secret, self.layernext_url)
|
|
2263
|
+
item_type_enum = 2
|
|
2264
|
+
if item_type == "image":
|
|
2265
|
+
item_type_enum = ObjectType.IMAGE.value
|
|
2266
|
+
elif item_type == "video":
|
|
2267
|
+
item_type_enum = ObjectType.VIDEO.value
|
|
2268
|
+
elif item_type == "other":
|
|
2269
|
+
item_type_enum = ObjectType.OTHER.value
|
|
2270
|
+
elif item_type == "image_collection":
|
|
2271
|
+
item_type_enum = ObjectType.IMAGE_COLLECTION.value
|
|
2272
|
+
elif item_type == "video_collection":
|
|
2273
|
+
item_type_enum = ObjectType.VIDEO_COLLECTION.value
|
|
2274
|
+
elif item_type == "other_collection":
|
|
2275
|
+
item_type_enum = ObjectType.OTHER_COLLECTION.value
|
|
2276
|
+
elif item_type == "dataset":
|
|
2277
|
+
item_type_enum = ObjectType.DATASET.value
|
|
2278
|
+
|
|
2279
|
+
filter = self.__create_filter(filter)
|
|
2280
|
+
return _datalake_client.get_item_count_from_metalake(
|
|
2281
|
+
item_type_enum,
|
|
2282
|
+
query,
|
|
2283
|
+
filter,
|
|
2284
|
+
)
|
|
2152
2285
|
|
|
2153
2286
|
"""
|
|
2154
2287
|
download files from collection(videos, images, others)
|
|
@@ -2343,6 +2476,61 @@ class LayerNextClient:
|
|
|
2343
2476
|
page_size,
|
|
2344
2477
|
sort_filter
|
|
2345
2478
|
)
|
|
2479
|
+
|
|
2480
|
+
"""
|
|
2481
|
+
get item count from collection in datalake
|
|
2482
|
+
@collection_id: id of the collection
|
|
2483
|
+
@query: datalake query
|
|
2484
|
+
@filter: {date: {fromDate: "", toDate: ""}, "annotation_types": ["human", "raw", "machine"]}
|
|
2485
|
+
"""
|
|
2486
|
+
def get_item_count_from_collection(
|
|
2487
|
+
self,
|
|
2488
|
+
collection_id,
|
|
2489
|
+
query: str = "",
|
|
2490
|
+
filter={},
|
|
2491
|
+
):
|
|
2492
|
+
|
|
2493
|
+
_datalake_client = datalake.DatalakeClient(
|
|
2494
|
+
self.encoded_key_secret, self.layernext_url)
|
|
2495
|
+
item_type_enum = 2
|
|
2496
|
+
if collection_id == None or collection_id == "":
|
|
2497
|
+
return {
|
|
2498
|
+
"isSuccess": False,
|
|
2499
|
+
"error": 'collection id must be provided'
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
object_type_object = self.__get_object_type_by_id(collection_id)
|
|
2503
|
+
object_type = None
|
|
2504
|
+
if "objectType" in object_type_object:
|
|
2505
|
+
object_type = object_type_object["objectType"]
|
|
2506
|
+
|
|
2507
|
+
if object_type == None:
|
|
2508
|
+
print('object type cannot find for collection id')
|
|
2509
|
+
return {
|
|
2510
|
+
"isSuccess": False,
|
|
2511
|
+
"error": 'object type cannot find for collection id'
|
|
2512
|
+
}
|
|
2513
|
+
if object_type == ObjectType.IMAGE_COLLECTION.value:
|
|
2514
|
+
item_type_enum = ObjectType.IMAGE.value
|
|
2515
|
+
elif object_type == ObjectType.VIDEO_COLLECTION.value:
|
|
2516
|
+
item_type_enum = ObjectType.VIDEO.value
|
|
2517
|
+
elif object_type == ObjectType.OTHER_COLLECTION.value:
|
|
2518
|
+
item_type_enum = ObjectType.OTHER.value
|
|
2519
|
+
else:
|
|
2520
|
+
return {
|
|
2521
|
+
"isSuccess": False,
|
|
2522
|
+
"error": 'collection type is not acceptable get item list'
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
filter = self.__create_filter(filter)
|
|
2526
|
+
# filter["contentType"] = item_type_enum
|
|
2527
|
+
|
|
2528
|
+
return _datalake_client.get_item_count_from_collection(
|
|
2529
|
+
item_type_enum,
|
|
2530
|
+
collection_id,
|
|
2531
|
+
query,
|
|
2532
|
+
filter,
|
|
2533
|
+
)
|
|
2346
2534
|
|
|
2347
2535
|
"""
|
|
2348
2536
|
Use for insert embedding list to images
|
|
@@ -2360,7 +2548,7 @@ class LayerNextClient:
|
|
|
2360
2548
|
embedding vector dimension limit 2048
|
|
2361
2549
|
"""
|
|
2362
2550
|
|
|
2363
|
-
def insert_image_embeddings_batch(self, embedding_list: List[Dict[str, List[float]]], model_name: str, vector_dimension: List[int]):
|
|
2551
|
+
def insert_image_embeddings_batch(self, embedding_list: List[Dict[str, List[float]]], model_name: str, vector_dimension: List[int], session_id: str= ""):
|
|
2364
2552
|
if embedding_list == None:
|
|
2365
2553
|
return {
|
|
2366
2554
|
"success": False,
|
|
@@ -2394,7 +2582,7 @@ class LayerNextClient:
|
|
|
2394
2582
|
_datalake_client = datalake.DatalakeClient(
|
|
2395
2583
|
self.encoded_key_secret, self.layernext_url)
|
|
2396
2584
|
|
|
2397
|
-
return _datalake_client.insert_embeddings_batch(embedding_list, model_name, vector_dimension)
|
|
2585
|
+
return _datalake_client.insert_embeddings_batch(embedding_list, model_name, vector_dimension, session_id)
|
|
2398
2586
|
|
|
2399
2587
|
"""
|
|
2400
2588
|
Use for insert embedding list to images
|
|
@@ -2410,10 +2598,13 @@ class LayerNextClient:
|
|
|
2410
2598
|
]
|
|
2411
2599
|
uniqueName string length limit 256 characters
|
|
2412
2600
|
embedding vector dimension limit 2048
|
|
2413
|
-
"""
|
|
2414
|
-
|
|
2601
|
+
"""
|
|
2415
2602
|
def insert_image_embeddings(
|
|
2416
2603
|
self, embedding_list: List[Dict[str, List[float]]], model_name: str, vector_dimension: List[int]) -> dict:
|
|
2604
|
+
|
|
2605
|
+
total_count = len(embedding_list)
|
|
2606
|
+
session_uuid = str(datetime.datetime.now().timestamp())
|
|
2607
|
+
job_name = f"Embedding-upload-{model_name}"
|
|
2417
2608
|
if embedding_list == None:
|
|
2418
2609
|
return {
|
|
2419
2610
|
"success": False,
|
|
@@ -2424,19 +2615,40 @@ class LayerNextClient:
|
|
|
2424
2615
|
"success": False,
|
|
2425
2616
|
"message": "embedding_list is not a list"
|
|
2426
2617
|
}
|
|
2618
|
+
|
|
2619
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, 0, JobStatus.QUEUED.value, {"modelName":model_name, "embeddingUploadTotalCount":total_count})
|
|
2620
|
+
|
|
2427
2621
|
count = 0
|
|
2622
|
+
continues_count = 0
|
|
2623
|
+
object_key_list = []
|
|
2428
2624
|
temp_embedding_list = []
|
|
2625
|
+
status = JobStatus.IN_PROGRESS.value
|
|
2429
2626
|
inserted_count = 0
|
|
2430
2627
|
message_list = []
|
|
2431
2628
|
for embedding in embedding_list:
|
|
2432
2629
|
if count == len(embedding_list)-1:
|
|
2630
|
+
|
|
2433
2631
|
temp_embedding_list.append(embedding)
|
|
2632
|
+
if('uniqueName' in embedding and isinstance(embedding['uniqueName'], str)):
|
|
2633
|
+
object_key_list.append(embedding['uniqueName'])
|
|
2634
|
+
else:
|
|
2635
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, 0, JobStatus.FAILED.value, {"errorList": f"Invalid embedding object: {embedding}"})
|
|
2636
|
+
return {"success":False}
|
|
2637
|
+
|
|
2434
2638
|
response = self.insert_image_embeddings_batch(
|
|
2435
2639
|
temp_embedding_list, model_name, vector_dimension)
|
|
2436
2640
|
if response["message"] != "":
|
|
2437
2641
|
message_list.append(response["message"])
|
|
2438
2642
|
if response["success"] == False:
|
|
2643
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, 0, JobStatus.FAILED.value, {"embeddingUploadTryObjectKeys":object_key_list,"errorList":"Error occur while uploading embeddings"})
|
|
2644
|
+
object_key_list = []
|
|
2439
2645
|
return response
|
|
2646
|
+
|
|
2647
|
+
progress = (continues_count/total_count)*100
|
|
2648
|
+
if (progress == 100):
|
|
2649
|
+
status = JobStatus.COMPLETED.value
|
|
2650
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, progress, status, {"embeddingUploadSuccessObjectKeys":object_key_list, "embeddingUploadSuccessCount": continues_count})
|
|
2651
|
+
object_key_list = []
|
|
2440
2652
|
inserted_count += response["upsert_count"]
|
|
2441
2653
|
return {
|
|
2442
2654
|
"success": True,
|
|
@@ -2449,13 +2661,32 @@ class LayerNextClient:
|
|
|
2449
2661
|
if response["message"] != "":
|
|
2450
2662
|
message_list.append(response["message"])
|
|
2451
2663
|
if response["success"] == False:
|
|
2664
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, 0, JobStatus.FAILED.value, {"embeddingUploadTryObjectKeys":object_key_list,"errorList":"Error occur while uploading embeddings"})
|
|
2665
|
+
object_key_list = []
|
|
2452
2666
|
return response
|
|
2667
|
+
|
|
2668
|
+
progress = (continues_count/total_count)*100
|
|
2669
|
+
if (progress == 100):
|
|
2670
|
+
status = JobStatus.COMPLETED.value
|
|
2671
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, progress, status, {"embeddingUploadSuccessObjectKeys":object_key_list, "embeddingUploadSuccessCount":continues_count})
|
|
2672
|
+
object_key_list = []
|
|
2453
2673
|
inserted_count += response["upsert_count"]
|
|
2454
2674
|
temp_embedding_list = []
|
|
2455
2675
|
else:
|
|
2456
2676
|
temp_embedding_list.append(embedding)
|
|
2677
|
+
if('uniqueName' in embedding and isinstance(embedding['uniqueName'], str)):
|
|
2678
|
+
object_key_list.append(embedding['uniqueName'])
|
|
2679
|
+
else:
|
|
2680
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, 0, JobStatus.FAILED.value, {"errorList": f"Invalid embedding object: {embedding}"})
|
|
2681
|
+
return {"success":False}
|
|
2457
2682
|
count += 1
|
|
2683
|
+
continues_count += 1
|
|
2458
2684
|
|
|
2685
|
+
progress = (continues_count/total_count)*100
|
|
2686
|
+
if (progress == 100):
|
|
2687
|
+
status = JobStatus.COMPLETED.value
|
|
2688
|
+
self.create_or_update_job(session_uuid, job_name,JobType.UPLOAD_EMBEDDING.value, progress, status, {"embeddingUploadSuccessObjectKeys":object_key_list, "embeddingUploadSuccessCount":continues_count})
|
|
2689
|
+
object_key_list = []
|
|
2459
2690
|
return {
|
|
2460
2691
|
"success": True,
|
|
2461
2692
|
"upsert_count": inserted_count,
|
|
@@ -2487,3 +2718,29 @@ class LayerNextClient:
|
|
|
2487
2718
|
unique_names,
|
|
2488
2719
|
model_name
|
|
2489
2720
|
)
|
|
2721
|
+
|
|
2722
|
+
def create_or_update_job(
|
|
2723
|
+
self,
|
|
2724
|
+
session_id:str,
|
|
2725
|
+
job_name:str,
|
|
2726
|
+
job_type:int,
|
|
2727
|
+
progress:int,
|
|
2728
|
+
status:int,
|
|
2729
|
+
job_detail:dict={}
|
|
2730
|
+
):
|
|
2731
|
+
|
|
2732
|
+
if(not isinstance(session_id, str) or not isinstance(job_name, str) or not isinstance(progress, (int, float)) or not isinstance(JobStatus(status), JobStatus) or not isinstance(JobType(job_type), JobType)):
|
|
2733
|
+
print("Invalid input field. Please check and retry")
|
|
2734
|
+
raise Exception("Cannot create or update job. Invalid input field. Please check and retry")
|
|
2735
|
+
|
|
2736
|
+
_datalake_client = datalake.DatalakeClient(
|
|
2737
|
+
self.encoded_key_secret, self.layernext_url)
|
|
2738
|
+
|
|
2739
|
+
return _datalake_client.create_or_update_job(
|
|
2740
|
+
session_id,
|
|
2741
|
+
job_name,
|
|
2742
|
+
job_type,
|
|
2743
|
+
progress,
|
|
2744
|
+
status,
|
|
2745
|
+
job_detail
|
|
2746
|
+
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
from .automatic_analysis_interface import AutomaticAnalysisInterface
|
|
2
|
-
from .
|
|
1
|
+
from layernext.automatic_analysis.automatic_analysis_interface import AutomaticAnalysisInterface
|
|
2
|
+
from .automatic_analysis import AutomaticAnalysis
|
|
3
|
+
from .support import make_tarfile_in_memory, validate_input_prompt, validate_input_annotation_type, validate_confidence, validate_task, validate_resolution_input
|
|
3
4
|
"""
|
|
4
5
|
Class to initiate AutomaticAnalysisClient and handle functions integrated to it
|
|
5
6
|
"""
|
|
@@ -14,6 +15,7 @@ class AutomaticAnalysisClient:
|
|
|
14
15
|
_automatic_analysis_url = f'{layernext_url}/analytics'
|
|
15
16
|
self.encoded_key_secret=encoded_key_secret
|
|
16
17
|
self.layernext_url=layernext_url
|
|
18
|
+
self.automatic_analysis = AutomaticAnalysis(encoded_key_secret, _automatic_analysis_url)
|
|
17
19
|
self.automatic_analysis_interface = AutomaticAnalysisInterface(encoded_key_secret, _automatic_analysis_url)
|
|
18
20
|
|
|
19
21
|
|
|
@@ -31,10 +33,12 @@ class AutomaticAnalysisClient:
|
|
|
31
33
|
_datalake_client,
|
|
32
34
|
task
|
|
33
35
|
):
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
try:
|
|
37
|
+
validate_task(task)
|
|
38
|
+
storage_url,bucket_name, object_key, label_list,model_name=make_tarfile_in_memory(input_model_path, model_id, _datalake_client)
|
|
39
|
+
self.automatic_analysis_interface.inference_model_upload(storage_url,bucket_name, object_key,model_id,label_list,model_name, task)
|
|
40
|
+
except ValueError as e:
|
|
41
|
+
print(f"ValueError: {e}")
|
|
38
42
|
|
|
39
43
|
"""
|
|
40
44
|
initiate the API call to the flask app to autotagging a given collection through tagger_detail_send
|
|
@@ -48,13 +52,21 @@ class AutomaticAnalysisClient:
|
|
|
48
52
|
collection_id,
|
|
49
53
|
model_id,
|
|
50
54
|
input_resolution,
|
|
51
|
-
confidence_threshold
|
|
55
|
+
confidence_threshold,
|
|
56
|
+
session_id,
|
|
57
|
+
job_id,
|
|
58
|
+
job_name
|
|
52
59
|
):
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
try:
|
|
61
|
+
validate_confidence(confidence_threshold)
|
|
62
|
+
validate_resolution_input(input_resolution)
|
|
63
|
+
application='collection_autotag'
|
|
64
|
+
item_type=""
|
|
65
|
+
self.automatic_analysis.tagger_detail_send(
|
|
66
|
+
application, collection_id, item_type, model_id, input_resolution, confidence_threshold,session_id,job_id,job_name)
|
|
67
|
+
except ValueError as e:
|
|
68
|
+
print(f"ValueError: {e}")
|
|
69
|
+
|
|
58
70
|
"""
|
|
59
71
|
initiate the API call to the flask app to autotagging a given item type files through tagger_detail_send
|
|
60
72
|
@param item_type : "image", "video", "other", "image_collection", "video_collection", "other_collection", "dataset"
|
|
@@ -67,13 +79,20 @@ class AutomaticAnalysisClient:
|
|
|
67
79
|
item_type,
|
|
68
80
|
model_id,
|
|
69
81
|
input_resolution,
|
|
70
|
-
confidence_threshold
|
|
82
|
+
confidence_threshold,
|
|
83
|
+
session_id,
|
|
84
|
+
job_id,
|
|
85
|
+
job_name
|
|
71
86
|
):
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
try:
|
|
88
|
+
application='population_autotag'
|
|
89
|
+
collection_id=""
|
|
90
|
+
validate_confidence(confidence_threshold)
|
|
91
|
+
validate_resolution_input(input_resolution)
|
|
92
|
+
self.automatic_analysis.tagger_detail_send(
|
|
93
|
+
application,collection_id,item_type,model_id,input_resolution, confidence_threshold,session_id,job_id,job_name)
|
|
94
|
+
except ValueError as e:
|
|
95
|
+
print(f"ValueError: {e}")
|
|
77
96
|
|
|
78
97
|
"""
|
|
79
98
|
auto annotating a given frames of an annotation project
|
|
@@ -82,20 +101,47 @@ class AutomaticAnalysisClient:
|
|
|
82
101
|
@param annotation_type : bounding box annotation or polygon segment annotation
|
|
83
102
|
@param model_id : id/name of the model which is registered in the datalake
|
|
84
103
|
@param confidence_threshold : confidence score to consider which objects/segments to consider for the proccedings
|
|
104
|
+
@auto_annotation_operation : Operation to do , sam-text, sam-img-encoding
|
|
85
105
|
"""
|
|
86
106
|
def model_annotate_collection(
|
|
87
107
|
self,
|
|
88
108
|
project_id,
|
|
89
109
|
model_id,
|
|
90
|
-
prompt,
|
|
110
|
+
# prompt,
|
|
91
111
|
annotation_type,
|
|
92
|
-
confidence_threshold
|
|
112
|
+
# confidence_threshold,
|
|
113
|
+
# auto_annotation_operation
|
|
114
|
+
**kwargs
|
|
93
115
|
):
|
|
94
116
|
|
|
95
117
|
application='collection_autoannotate'
|
|
96
|
-
|
|
97
|
-
application,project_id,model_id, prompt, annotation_type, confidence_threshold)
|
|
118
|
+
|
|
98
119
|
|
|
120
|
+
try:
|
|
121
|
+
validate_input_annotation_type(annotation_type)
|
|
122
|
+
if "prompt" in kwargs:
|
|
123
|
+
validate_input_prompt(kwargs["prompt"])
|
|
124
|
+
if "confidence_threshold" in kwargs:
|
|
125
|
+
validate_confidence(kwargs["confidence_threshold"])
|
|
126
|
+
self.automatic_analysis.annotater_detail_send(
|
|
127
|
+
application,project_id,model_id, annotation_type, **kwargs)
|
|
128
|
+
except ValueError as e:
|
|
129
|
+
print(f"ValueError: {e}")
|
|
130
|
+
|
|
131
|
+
def prompt_infer_image(
|
|
132
|
+
self,
|
|
133
|
+
name,
|
|
134
|
+
shape,
|
|
135
|
+
**kwargs
|
|
136
|
+
):
|
|
137
|
+
|
|
138
|
+
try:
|
|
139
|
+
self.automatic_analysis_interface.prompt_detail_send(
|
|
140
|
+
name,
|
|
141
|
+
shape, **kwargs)
|
|
142
|
+
except ValueError as e:
|
|
143
|
+
print(f"ValueError: {e}")
|
|
144
|
+
|
|
99
145
|
"""
|
|
100
146
|
generate embedding for a given collection (image) and upload the embeddings to the vector database
|
|
101
147
|
@param collection_id: id of the image.
|
|
@@ -104,8 +150,32 @@ class AutomaticAnalysisClient:
|
|
|
104
150
|
def embedding_model_inference_collection(
|
|
105
151
|
self,
|
|
106
152
|
collection_id,
|
|
107
|
-
model_id
|
|
153
|
+
model_id,
|
|
154
|
+
query,
|
|
155
|
+
filters,
|
|
156
|
+
session_id,
|
|
157
|
+
job_id,
|
|
158
|
+
job_name):
|
|
108
159
|
|
|
109
160
|
application ='collection_embedding'
|
|
110
|
-
|
|
111
|
-
|
|
161
|
+
item_type=""
|
|
162
|
+
return self.automatic_analysis.embedding_detail_send(
|
|
163
|
+
collection_id, model_id, application,item_type, query, filters, session_id,job_id,job_name)
|
|
164
|
+
|
|
165
|
+
def model_embedding_population(
|
|
166
|
+
self,
|
|
167
|
+
item_type,
|
|
168
|
+
model_id,
|
|
169
|
+
query,
|
|
170
|
+
filters,
|
|
171
|
+
session_id,
|
|
172
|
+
job_id,
|
|
173
|
+
job_name
|
|
174
|
+
):
|
|
175
|
+
try:
|
|
176
|
+
application='population_embedding'
|
|
177
|
+
collection_id=""
|
|
178
|
+
return self.automatic_analysis.embedding_detail_send(
|
|
179
|
+
collection_id, model_id, application,item_type, query, filters, session_id, job_id, job_name)
|
|
180
|
+
except ValueError as e:
|
|
181
|
+
print(f"ValueError: {e}")
|