clarifai 9.1.0__py3-none-any.whl → 9.3.1__py3-none-any.whl
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.
- clarifai/data_upload/datasets/__init__.py +0 -0
- clarifai/data_upload/datasets/base.py +67 -0
- clarifai/data_upload/datasets/features.py +45 -0
- clarifai/data_upload/datasets/image.py +236 -0
- clarifai/data_upload/datasets/text.py +62 -0
- clarifai/data_upload/datasets/zoo/__init__.py +0 -0
- clarifai/data_upload/datasets/zoo/coco_captions.py +99 -0
- clarifai/data_upload/datasets/zoo/coco_detection.py +129 -0
- clarifai/data_upload/datasets/zoo/coco_segmentation.py +158 -0
- clarifai/data_upload/examples.py +19 -0
- clarifai/data_upload/upload.py +269 -168
- clarifai/listing/installed_module_versions.py +3 -14
- clarifai/listing/lister.py +40 -0
- clarifai/listing/module_versions.py +42 -0
- clarifai/listing/modules.py +36 -0
- clarifai/modules/style.css +7 -4
- {clarifai-9.1.0.dist-info → clarifai-9.3.1.dist-info}/METADATA +3 -3
- {clarifai-9.1.0.dist-info → clarifai-9.3.1.dist-info}/RECORD +37 -13
- clarifai_utils/data_upload/datasets/__init__.py +0 -0
- clarifai_utils/data_upload/datasets/base.py +67 -0
- clarifai_utils/data_upload/datasets/features.py +45 -0
- clarifai_utils/data_upload/datasets/image.py +236 -0
- clarifai_utils/data_upload/datasets/text.py +62 -0
- clarifai_utils/data_upload/datasets/zoo/__init__.py +0 -0
- clarifai_utils/data_upload/datasets/zoo/coco_captions.py +99 -0
- clarifai_utils/data_upload/datasets/zoo/coco_detection.py +129 -0
- clarifai_utils/data_upload/datasets/zoo/coco_segmentation.py +158 -0
- clarifai_utils/data_upload/examples.py +19 -0
- clarifai_utils/data_upload/upload.py +269 -168
- clarifai_utils/listing/installed_module_versions.py +3 -14
- clarifai_utils/listing/lister.py +40 -0
- clarifai_utils/listing/module_versions.py +42 -0
- clarifai_utils/listing/modules.py +36 -0
- clarifai_utils/modules/style.css +7 -4
- {clarifai-9.1.0.dist-info → clarifai-9.3.1.dist-info}/LICENSE +0 -0
- {clarifai-9.1.0.dist-info → clarifai-9.3.1.dist-info}/WHEEL +0 -0
- {clarifai-9.1.0.dist-info → clarifai-9.3.1.dist-info}/top_level.txt +0 -0
clarifai/listing/lister.py
CHANGED
|
@@ -6,6 +6,8 @@ from clarifai.listing.datasets import datasets_generator
|
|
|
6
6
|
from clarifai.listing.inputs import dataset_inputs_generator, inputs_generator
|
|
7
7
|
from clarifai.listing.installed_module_versions import installed_module_versions_generator
|
|
8
8
|
from clarifai.listing.models import models_generator
|
|
9
|
+
from clarifai.listing.module_versions import module_versions_generator
|
|
10
|
+
from clarifai.listing.modules import modules_generator
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class ClarifaiResourceLister(object):
|
|
@@ -158,3 +160,41 @@ class ClarifaiResourceLister(object):
|
|
|
158
160
|
"""
|
|
159
161
|
page_size = self.default_page_size if page_size is None else page_size
|
|
160
162
|
return installed_module_versions_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
163
|
+
|
|
164
|
+
def list_all_modules(self, page_size: int = None):
|
|
165
|
+
"""
|
|
166
|
+
This lists all the modules in an app. Not recommended for large apps.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
modules: a list of Module protos for all the modules in the app.
|
|
170
|
+
"""
|
|
171
|
+
return [item for item in self.module_generator(page_size)]
|
|
172
|
+
|
|
173
|
+
def module_generator(self, page_size: int = None):
|
|
174
|
+
"""
|
|
175
|
+
This lists all the module in an app. Not recommended for large apps.
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
gen: a generator that yields a single Module proto at a time.
|
|
179
|
+
"""
|
|
180
|
+
page_size = self.default_page_size if page_size is None else page_size
|
|
181
|
+
return modules_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
182
|
+
|
|
183
|
+
def list_all_module_versions(self, page_size: int = None):
|
|
184
|
+
"""
|
|
185
|
+
This lists all the module_versions in an app. Not recommended for large apps.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
module_versions: a list of ModuleVersion protos for all the module_versions in the app.
|
|
189
|
+
"""
|
|
190
|
+
return [item for item in self.module_versions_generator(page_size)]
|
|
191
|
+
|
|
192
|
+
def module_versions_generator(self, page_size: int = None):
|
|
193
|
+
"""
|
|
194
|
+
This lists all the module_versions in an app. Not recommended for large apps.
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
gen: a generator that yields a single ModuleVersion proto at a time.
|
|
198
|
+
"""
|
|
199
|
+
page_size = self.default_page_size if page_size is None else page_size
|
|
200
|
+
return module_versions_generator(self.stub, self.user_id, self.app_id, page_size)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
|
|
2
|
+
from clarifai_grpc.grpc.api.status import status_code_pb2
|
|
3
|
+
|
|
4
|
+
from clarifai.client import V2Stub
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def module_versions_generator(stub: V2Stub,
|
|
8
|
+
user_id: str,
|
|
9
|
+
app_id: str,
|
|
10
|
+
module_id: str,
|
|
11
|
+
page_size: int = 64):
|
|
12
|
+
"""
|
|
13
|
+
Lists all the module versions in the given userAppID user_id, app_id app, module_id module.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
stub: client stub.
|
|
17
|
+
user_id: the user to list from.
|
|
18
|
+
app_id: the app in the user_id account to list from.
|
|
19
|
+
module_id: the module in the app to list from.
|
|
20
|
+
page_size: the pagination size to use while iterating.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
module_versions: a list of ModuleVersion protos for all the modules in the app.
|
|
24
|
+
"""
|
|
25
|
+
userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
26
|
+
|
|
27
|
+
success_status = {status_code_pb2.SUCCESS}
|
|
28
|
+
|
|
29
|
+
page = 1
|
|
30
|
+
while True:
|
|
31
|
+
response = stub.ListModuleVersions(
|
|
32
|
+
service_pb2.ListModuleVersionsRequest(
|
|
33
|
+
user_app_id=userDataObject, module_id=module_id, page=page, per_page=page_size),)
|
|
34
|
+
|
|
35
|
+
if response.status.code not in success_status:
|
|
36
|
+
raise Exception("ListModuleVersions failed with response %r" % response)
|
|
37
|
+
for item in response.module_versions:
|
|
38
|
+
yield item
|
|
39
|
+
page += 1
|
|
40
|
+
# if we don't get a full page back we know we're done.
|
|
41
|
+
if len(response.module_versions) < page_size:
|
|
42
|
+
break
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from clarifai_grpc.grpc.api import resources_pb2, service_pb2
|
|
2
|
+
from clarifai_grpc.grpc.api.status import status_code_pb2
|
|
3
|
+
|
|
4
|
+
from clarifai.client import V2Stub
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def modules_generator(stub: V2Stub, user_id: str, app_id: str, page_size: int = 64):
|
|
8
|
+
"""
|
|
9
|
+
Lists all the modules in the given userAppID user_id, app_id app.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
stub: client stub.
|
|
13
|
+
user_id: the user to list from.
|
|
14
|
+
app_id: the app in the user_id account to list from.
|
|
15
|
+
page_size: the pagination size to use while iterating.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
imvs: a list of Module protos for all the modules in the app.
|
|
19
|
+
"""
|
|
20
|
+
userDataObject = resources_pb2.UserAppIDSet(user_id=user_id, app_id=app_id)
|
|
21
|
+
|
|
22
|
+
success_status = {status_code_pb2.SUCCESS}
|
|
23
|
+
|
|
24
|
+
page = 1
|
|
25
|
+
while True:
|
|
26
|
+
response = stub.ListModules(
|
|
27
|
+
service_pb2.ListModulesRequest(user_app_id=userDataObject, page=page, per_page=page_size),)
|
|
28
|
+
|
|
29
|
+
if response.status.code not in success_status:
|
|
30
|
+
raise Exception("ListModules failed with response %r" % response)
|
|
31
|
+
for item in response.modules:
|
|
32
|
+
yield item
|
|
33
|
+
page += 1
|
|
34
|
+
# if we don't get a full page back we know we're done.
|
|
35
|
+
if len(response.modules) < page_size:
|
|
36
|
+
break
|
clarifai/modules/style.css
CHANGED
|
@@ -80,7 +80,7 @@ body {
|
|
|
80
80
|
color: #fff;
|
|
81
81
|
background-color: #006dff;
|
|
82
82
|
border-color: transparent;
|
|
83
|
-
border-radius: 0
|
|
83
|
+
border-radius: 0 7px 7px 0;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
.stTextArea > div {
|
|
@@ -95,6 +95,12 @@ body {
|
|
|
95
95
|
border-radius: 8px;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
.stNumberInput>div {
|
|
99
|
+
color: #fff;
|
|
100
|
+
border-color: #e4e7ec;
|
|
101
|
+
border-radius: 8px 8px 8px 8px;
|
|
102
|
+
}
|
|
103
|
+
|
|
98
104
|
.stNumberInput>div>div>button {
|
|
99
105
|
color: #fff;
|
|
100
106
|
background-color: #006dff;
|
|
@@ -139,9 +145,6 @@ div[data-testid="stFileUploader"]>section>button:active
|
|
|
139
145
|
background-color: #356dff;
|
|
140
146
|
}
|
|
141
147
|
|
|
142
|
-
.st-bt {
|
|
143
|
-
background-color: #fff;
|
|
144
|
-
}
|
|
145
148
|
|
|
146
149
|
.stTextInput>div>div>input {
|
|
147
150
|
background-color: #fff;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: clarifai
|
|
3
|
-
Version: 9.1
|
|
3
|
+
Version: 9.3.1
|
|
4
4
|
Summary: Clarifai Python Utilities
|
|
5
5
|
Home-page: https://github.com/Clarifai/clarifai-python-utils
|
|
6
6
|
Author: Clarifai
|
|
@@ -10,10 +10,10 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: clarifai-grpc (>=9.
|
|
16
|
+
Requires-Dist: clarifai-grpc (>=9.3.0)
|
|
17
17
|
|
|
18
18
|

|
|
19
19
|
|
|
@@ -7,19 +7,31 @@ clarifai/client/stub.py,sha256=pa1Sh9HeUG7Ipi3f-OmTRFp0hvH31PF60NsC7IwFBNI,3606
|
|
|
7
7
|
clarifai/data_upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
clarifai/data_upload/base.py,sha256=D3ZXFij9tlSmO53tARqsrMNVgo-m4wmshjxwilRGcSs,2042
|
|
9
9
|
clarifai/data_upload/datasets.py,sha256=KQ4I9frenTcXJh94PO7f-jZd74cNisiRmuBuLA1ArlI,10845
|
|
10
|
-
clarifai/data_upload/
|
|
10
|
+
clarifai/data_upload/examples.py,sha256=7GuewOZtaBB7z67XVRinc7s0uIcBxTdrwVa_PJ1ODww,540
|
|
11
|
+
clarifai/data_upload/upload.py,sha256=925LqVP1k0Aypp9CX32AO_zzPiqEM7OK4IXHmWHX3mw,10917
|
|
11
12
|
clarifai/data_upload/utils.py,sha256=zHIIbX7O9SZTFmJJqZ1j5nmh23AHt4VyNnYPQQMrD8I,6328
|
|
13
|
+
clarifai/data_upload/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
clarifai/data_upload/datasets/base.py,sha256=EtI_AoJVWUvP4h1IWIefkTijjhsQKvvfW0BJOHmNsN4,1693
|
|
15
|
+
clarifai/data_upload/datasets/features.py,sha256=7bC2lXBJQk9k3RJBLI69tWv1GK6MNs4WHWZFsJ6V1y0,1089
|
|
16
|
+
clarifai/data_upload/datasets/image.py,sha256=HL9mV5FkYQWWihoVRAolZfu8pYIqW9Hd0EsLJsHpt94,9235
|
|
17
|
+
clarifai/data_upload/datasets/text.py,sha256=IxLPBhoh4dDdrI41zTMGArNIAc3Z-C8KPIxVpUZ6tlw,2110
|
|
18
|
+
clarifai/data_upload/datasets/zoo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
+
clarifai/data_upload/datasets/zoo/coco_captions.py,sha256=GcBdV5R7zY7zF4QEEr293cd2JQZeFuseyYUJG-yBU_c,3651
|
|
20
|
+
clarifai/data_upload/datasets/zoo/coco_detection.py,sha256=Pj0PXlzE3RHueepCxxmtQWFjyCBz0R_eLcbGCAQJ7nM,4856
|
|
21
|
+
clarifai/data_upload/datasets/zoo/coco_segmentation.py,sha256=ap309aTc5mv_7VOBG5m9wer1BygTTHZ-e3H8Zg6rcOo,6196
|
|
12
22
|
clarifai/listing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
23
|
clarifai/listing/concepts.py,sha256=AbdZZ_EFj5P8DvPp9mIm9UlWCUusILjsQ3YJtXoeBvA,1169
|
|
14
24
|
clarifai/listing/datasets.py,sha256=mlm0TRm60JyVT6GGRwhvfDqsBm2Z64SxHOv_CyFFhuk,1184
|
|
15
25
|
clarifai/listing/inputs.py,sha256=pmB5WQl1ArVwjh7tXsaSDMXuONqke5XSAChV_zSfi9w,3632
|
|
16
|
-
clarifai/listing/installed_module_versions.py,sha256=
|
|
17
|
-
clarifai/listing/lister.py,sha256=
|
|
26
|
+
clarifai/listing/installed_module_versions.py,sha256=3-s2YTylmbkt_Pcja3nDZ9yGatGrMNtojU3ia5UAdFQ,1466
|
|
27
|
+
clarifai/listing/lister.py,sha256=BoQXxoWNVNr7s1zEZ9oFADXck6kfcQFG-NjRzQ9mcwo,7710
|
|
18
28
|
clarifai/listing/models.py,sha256=AgINtzh8nE6nfFN9CqYI-ocSRwhsOiZohcutvziR150,1506
|
|
29
|
+
clarifai/listing/module_versions.py,sha256=M86Jm_Rdb6tPxuRY0exI3JGh1MSguoolo7wVzV3DeWk,1480
|
|
30
|
+
clarifai/listing/modules.py,sha256=yM074edY2d19HHt2MpO6_oAzDxM8yuc4hMns4D8zQTs,1170
|
|
19
31
|
clarifai/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
32
|
clarifai/modules/css.py,sha256=kadCEunmyh5h2yf0-4aysE3ZcZ6qaQcxuAgDXS96yF8,2020
|
|
21
33
|
clarifai/modules/pages.py,sha256=iOoM3RNRMgXlV0qBqcdQofxoXo2RuRQh0h9c9BIS0-I,1383
|
|
22
|
-
clarifai/modules/style.css,sha256=
|
|
34
|
+
clarifai/modules/style.css,sha256=nds6AFct5-jzXFwfj0tlybM4cSw-zZaONH6mdTFPi5I,4131
|
|
23
35
|
clarifai/urls/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
36
|
clarifai/urls/helper.py,sha256=2U5tjMPFAqAxVOPHpankt11LGxVWcLmu8tX1KTrmUp4,3172
|
|
25
37
|
clarifai_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -33,9 +45,19 @@ clarifai_utils/client/stub.py~,sha256=_EDjwtCbCahDzXNOSVkk0ZWVIkeca8c8akd3uAwQrl
|
|
|
33
45
|
clarifai_utils/data_upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
46
|
clarifai_utils/data_upload/base.py,sha256=D3ZXFij9tlSmO53tARqsrMNVgo-m4wmshjxwilRGcSs,2042
|
|
35
47
|
clarifai_utils/data_upload/datasets.py,sha256=KQ4I9frenTcXJh94PO7f-jZd74cNisiRmuBuLA1ArlI,10845
|
|
36
|
-
clarifai_utils/data_upload/
|
|
48
|
+
clarifai_utils/data_upload/examples.py,sha256=7GuewOZtaBB7z67XVRinc7s0uIcBxTdrwVa_PJ1ODww,540
|
|
49
|
+
clarifai_utils/data_upload/upload.py,sha256=925LqVP1k0Aypp9CX32AO_zzPiqEM7OK4IXHmWHX3mw,10917
|
|
37
50
|
clarifai_utils/data_upload/upload.py~,sha256=WHDT4t1Ok41NOgiManoYJRv2QX4QRC2Rckqbb517VHA,7089
|
|
38
51
|
clarifai_utils/data_upload/utils.py,sha256=zHIIbX7O9SZTFmJJqZ1j5nmh23AHt4VyNnYPQQMrD8I,6328
|
|
52
|
+
clarifai_utils/data_upload/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
|
+
clarifai_utils/data_upload/datasets/base.py,sha256=EtI_AoJVWUvP4h1IWIefkTijjhsQKvvfW0BJOHmNsN4,1693
|
|
54
|
+
clarifai_utils/data_upload/datasets/features.py,sha256=7bC2lXBJQk9k3RJBLI69tWv1GK6MNs4WHWZFsJ6V1y0,1089
|
|
55
|
+
clarifai_utils/data_upload/datasets/image.py,sha256=HL9mV5FkYQWWihoVRAolZfu8pYIqW9Hd0EsLJsHpt94,9235
|
|
56
|
+
clarifai_utils/data_upload/datasets/text.py,sha256=IxLPBhoh4dDdrI41zTMGArNIAc3Z-C8KPIxVpUZ6tlw,2110
|
|
57
|
+
clarifai_utils/data_upload/datasets/zoo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
|
+
clarifai_utils/data_upload/datasets/zoo/coco_captions.py,sha256=GcBdV5R7zY7zF4QEEr293cd2JQZeFuseyYUJG-yBU_c,3651
|
|
59
|
+
clarifai_utils/data_upload/datasets/zoo/coco_detection.py,sha256=Pj0PXlzE3RHueepCxxmtQWFjyCBz0R_eLcbGCAQJ7nM,4856
|
|
60
|
+
clarifai_utils/data_upload/datasets/zoo/coco_segmentation.py,sha256=ap309aTc5mv_7VOBG5m9wer1BygTTHZ-e3H8Zg6rcOo,6196
|
|
39
61
|
clarifai_utils/listing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
62
|
clarifai_utils/listing/concepts.py,sha256=AbdZZ_EFj5P8DvPp9mIm9UlWCUusILjsQ3YJtXoeBvA,1169
|
|
41
63
|
clarifai_utils/listing/concepts.py~,sha256=RnWzTK4ZFdrELWnEace3vgiqzB_prMmvAWNLFn0tz3w,1175
|
|
@@ -43,20 +65,22 @@ clarifai_utils/listing/datasets.py,sha256=mlm0TRm60JyVT6GGRwhvfDqsBm2Z64SxHOv_Cy
|
|
|
43
65
|
clarifai_utils/listing/datasets.py~,sha256=BH9F7gxpAbkgoIgC467DiWxO-K66h5ERPopQc43ah5Q,1190
|
|
44
66
|
clarifai_utils/listing/inputs.py,sha256=pmB5WQl1ArVwjh7tXsaSDMXuONqke5XSAChV_zSfi9w,3632
|
|
45
67
|
clarifai_utils/listing/inputs.py~,sha256=nPTTBVvCTAYLFNf4YGC7MP1KgBS_o3Ob75dmJ_cpLEA,3638
|
|
46
|
-
clarifai_utils/listing/installed_module_versions.py,sha256=
|
|
68
|
+
clarifai_utils/listing/installed_module_versions.py,sha256=3-s2YTylmbkt_Pcja3nDZ9yGatGrMNtojU3ia5UAdFQ,1466
|
|
47
69
|
clarifai_utils/listing/installed_module_versions.py~,sha256=GgJQ8DLQq9GEhgaa97XFRmNpthUKKpUE4vM40G9ljaY,1818
|
|
48
|
-
clarifai_utils/listing/lister.py,sha256=
|
|
70
|
+
clarifai_utils/listing/lister.py,sha256=BoQXxoWNVNr7s1zEZ9oFADXck6kfcQFG-NjRzQ9mcwo,7710
|
|
49
71
|
clarifai_utils/listing/lister.py~,sha256=bmAxbl4Wkb4S1rGBPHvG5TSLAtzuAvnBg_L5C9bR-0s,6198
|
|
50
72
|
clarifai_utils/listing/models.py,sha256=AgINtzh8nE6nfFN9CqYI-ocSRwhsOiZohcutvziR150,1506
|
|
51
73
|
clarifai_utils/listing/models.py~,sha256=i3Ls-lrtB-KO5LxNBxFb-KQxICROkeUgIx0naKivjDU,1512
|
|
74
|
+
clarifai_utils/listing/module_versions.py,sha256=M86Jm_Rdb6tPxuRY0exI3JGh1MSguoolo7wVzV3DeWk,1480
|
|
75
|
+
clarifai_utils/listing/modules.py,sha256=yM074edY2d19HHt2MpO6_oAzDxM8yuc4hMns4D8zQTs,1170
|
|
52
76
|
clarifai_utils/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
77
|
clarifai_utils/modules/css.py,sha256=kadCEunmyh5h2yf0-4aysE3ZcZ6qaQcxuAgDXS96yF8,2020
|
|
54
78
|
clarifai_utils/modules/pages.py,sha256=iOoM3RNRMgXlV0qBqcdQofxoXo2RuRQh0h9c9BIS0-I,1383
|
|
55
|
-
clarifai_utils/modules/style.css,sha256=
|
|
79
|
+
clarifai_utils/modules/style.css,sha256=nds6AFct5-jzXFwfj0tlybM4cSw-zZaONH6mdTFPi5I,4131
|
|
56
80
|
clarifai_utils/urls/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
57
81
|
clarifai_utils/urls/helper.py,sha256=2U5tjMPFAqAxVOPHpankt11LGxVWcLmu8tX1KTrmUp4,3172
|
|
58
|
-
clarifai-9.1.
|
|
59
|
-
clarifai-9.1.
|
|
60
|
-
clarifai-9.1.
|
|
61
|
-
clarifai-9.1.
|
|
62
|
-
clarifai-9.1.
|
|
82
|
+
clarifai-9.3.1.dist-info/LICENSE,sha256=GuQZ4iPZUwh44duTbVr7ZzYp_SaJDLR9MvzU7YqlZXM,555
|
|
83
|
+
clarifai-9.3.1.dist-info/METADATA,sha256=67jF3QVKCfQeH2B8-9GpwTb3TTBVbiaVNj1k7bZfmHc,2921
|
|
84
|
+
clarifai-9.3.1.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
85
|
+
clarifai-9.3.1.dist-info/top_level.txt,sha256=w3e8wx1HuK3_huGQosppv1_FSoNjBUd09KBKMK3wR-U,24
|
|
86
|
+
clarifai-9.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from typing import Iterator, List
|
|
2
|
+
|
|
3
|
+
from clarifai_grpc.grpc.api import resources_pb2
|
|
4
|
+
from google.protobuf.struct_pb2 import Struct
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ClarifaiDataset:
|
|
8
|
+
"""
|
|
9
|
+
Clarifai datasets base class.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, datagen_object: Iterator, dataset_id: str, split: str) -> None:
|
|
13
|
+
self.datagen_object = datagen_object
|
|
14
|
+
self.dataset_id = dataset_id
|
|
15
|
+
self.split = split
|
|
16
|
+
self._all_input_protos = []
|
|
17
|
+
|
|
18
|
+
def __len__(self) -> int:
|
|
19
|
+
"""
|
|
20
|
+
Get size of all input protos
|
|
21
|
+
"""
|
|
22
|
+
return len(self._all_input_protos)
|
|
23
|
+
|
|
24
|
+
def _to_list(self, input_protos: Iterator) -> List:
|
|
25
|
+
"""
|
|
26
|
+
Parse protos iterator to list.
|
|
27
|
+
"""
|
|
28
|
+
return list(input_protos)
|
|
29
|
+
|
|
30
|
+
def create_input_protos(self, image_path: str, label: str, input_id: str, dataset_id: str,
|
|
31
|
+
metadata: Struct) -> resources_pb2.Input:
|
|
32
|
+
"""
|
|
33
|
+
Create input protos for each image, label input pair.
|
|
34
|
+
Args:
|
|
35
|
+
`image_path`: path to image.
|
|
36
|
+
`label`: image label
|
|
37
|
+
`input_id: unique input id
|
|
38
|
+
`dataset_id`: Clarifai dataset id
|
|
39
|
+
`metadata`: input metadata
|
|
40
|
+
Returns:
|
|
41
|
+
An input proto representing a single row input
|
|
42
|
+
"""
|
|
43
|
+
raise NotImplementedError()
|
|
44
|
+
|
|
45
|
+
def _get_input_protos(self) -> Iterator:
|
|
46
|
+
"""
|
|
47
|
+
Create input protos for each row of the dataframe.
|
|
48
|
+
Returns:
|
|
49
|
+
A list of input protos
|
|
50
|
+
"""
|
|
51
|
+
raise NotImplementedError()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Chunker:
|
|
55
|
+
"""
|
|
56
|
+
Split an input sequence into small chunks.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def __init__(self, seq: List, size: int) -> None:
|
|
60
|
+
self.seq = seq
|
|
61
|
+
self.size = size
|
|
62
|
+
|
|
63
|
+
def chunk(self) -> List[List]:
|
|
64
|
+
"""
|
|
65
|
+
Chunk input sequence.
|
|
66
|
+
"""
|
|
67
|
+
return [self.seq[pos:pos + self.size] for pos in range(0, len(self.seq), self.size)]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#! dataset output features (output from preprocessing & input to clarifai data proto builders)
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import List, Optional, Union
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class TextFeatures:
|
|
8
|
+
"""
|
|
9
|
+
Text classification datasets preprocessing output features.
|
|
10
|
+
"""
|
|
11
|
+
text: str
|
|
12
|
+
labels: List[Union[str, int]] # List[str or int] to cater for multi-class tasks
|
|
13
|
+
id: Optional[int] = None # text_id
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass
|
|
17
|
+
class VisualClassificationFeatures:
|
|
18
|
+
"""
|
|
19
|
+
Image classification datasets preprocessing output features.
|
|
20
|
+
"""
|
|
21
|
+
image_path: str
|
|
22
|
+
label: Union[str, int]
|
|
23
|
+
id: Optional[int] = None # image_id
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class VisualDetectionFeatures:
|
|
28
|
+
"""
|
|
29
|
+
Image Detection datasets preprocessing output features.
|
|
30
|
+
"""
|
|
31
|
+
image_path: str
|
|
32
|
+
classes: List[Union[str, int]]
|
|
33
|
+
bboxes: List[List[float]]
|
|
34
|
+
id: Optional[int] = None # image_id
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
@dataclass
|
|
38
|
+
class VisualSegmentationFeatures:
|
|
39
|
+
"""
|
|
40
|
+
Image Segmentation datasets preprocessing output features.
|
|
41
|
+
"""
|
|
42
|
+
image_path: str
|
|
43
|
+
classes: List[Union[str]]
|
|
44
|
+
polygons: List[List[List[float]]]
|
|
45
|
+
id: Optional[int] = None # image_id
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
from typing import Iterator, List, Tuple, Union
|
|
2
|
+
|
|
3
|
+
from clarifai_grpc.grpc.api import resources_pb2
|
|
4
|
+
from google.protobuf.struct_pb2 import Struct
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
|
|
7
|
+
from .base import ClarifaiDataset
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class VisualClassificationDataset(ClarifaiDataset):
|
|
11
|
+
|
|
12
|
+
def __init__(self, datagen_object: Iterator, dataset_id: str, split: str) -> None:
|
|
13
|
+
super().__init__(datagen_object, dataset_id, split)
|
|
14
|
+
|
|
15
|
+
def create_input_protos(self, image_path: str, labels: List[Union[str, int]], input_id: str,
|
|
16
|
+
dataset_id: str, metadata: Struct) -> resources_pb2.Input:
|
|
17
|
+
"""
|
|
18
|
+
Create input protos for each image, label input pair.
|
|
19
|
+
Args:
|
|
20
|
+
`image_path`: image path.
|
|
21
|
+
`labels`: image label(s)
|
|
22
|
+
`input_id: unique input id
|
|
23
|
+
`dataset_id`: Clarifai dataset id
|
|
24
|
+
`metadata`: image metadata
|
|
25
|
+
Returns:
|
|
26
|
+
An input proto representing a single row input
|
|
27
|
+
"""
|
|
28
|
+
input_proto = resources_pb2.Input(
|
|
29
|
+
id=input_id,
|
|
30
|
+
dataset_ids=[dataset_id],
|
|
31
|
+
data=resources_pb2.Data(
|
|
32
|
+
image=resources_pb2.Image(base64=open(image_path, 'rb').read(),),
|
|
33
|
+
concepts=[
|
|
34
|
+
resources_pb2.Concept(
|
|
35
|
+
id=f"id-{''.join(_label.split(' '))}", name=_label, value=1.)\
|
|
36
|
+
for _label in labels
|
|
37
|
+
],
|
|
38
|
+
metadata=metadata))
|
|
39
|
+
|
|
40
|
+
return input_proto
|
|
41
|
+
|
|
42
|
+
def _get_input_protos(self) -> Iterator:
|
|
43
|
+
"""
|
|
44
|
+
Create input image protos for each data generator item.
|
|
45
|
+
Returns:
|
|
46
|
+
Input proto iterator
|
|
47
|
+
"""
|
|
48
|
+
for i, item in tqdm(enumerate(self.datagen_object), desc="Creating input protos..."):
|
|
49
|
+
metadata = Struct()
|
|
50
|
+
image_path = item.image_path
|
|
51
|
+
label = item.label if isinstance(item.label, list) else [item.label] # clarifai concept
|
|
52
|
+
input_id = f"{self.dataset_id}-{self.split}-{i}" if item.id is None else f"{self.split}-{str(item.id)}"
|
|
53
|
+
|
|
54
|
+
input_proto = self.create_input_protos(image_path, label, input_id, self.dataset_id,
|
|
55
|
+
metadata)
|
|
56
|
+
self._all_input_protos.append(input_proto)
|
|
57
|
+
|
|
58
|
+
return iter(self._all_input_protos)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class VisualDetectionDataset(ClarifaiDataset):
|
|
62
|
+
"""
|
|
63
|
+
Visual detection dataset proto class.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def __init__(self, datagen_object: Iterator, dataset_id: str, split: str) -> None:
|
|
67
|
+
super().__init__(datagen_object, dataset_id, split)
|
|
68
|
+
self._annotation_protos = []
|
|
69
|
+
|
|
70
|
+
def create_input_protos(self, image_path: str, input_id: str, dataset_id: str,
|
|
71
|
+
metadata: Struct) -> resources_pb2.Input:
|
|
72
|
+
"""
|
|
73
|
+
Create input protos for each image, label input pair.
|
|
74
|
+
Args:
|
|
75
|
+
`image_path`: file path to image
|
|
76
|
+
`input_id: unique input id
|
|
77
|
+
`dataset_id`: Clarifai dataset id
|
|
78
|
+
`metadata`: image metadata
|
|
79
|
+
Returns:
|
|
80
|
+
An input proto representing a single row input
|
|
81
|
+
"""
|
|
82
|
+
input_image_proto = resources_pb2.Input(
|
|
83
|
+
id=input_id,
|
|
84
|
+
dataset_ids=[dataset_id],
|
|
85
|
+
data=resources_pb2.Data(
|
|
86
|
+
image=resources_pb2.Image(base64=open(image_path, 'rb').read(),), metadata=metadata))
|
|
87
|
+
|
|
88
|
+
return input_image_proto
|
|
89
|
+
|
|
90
|
+
def create_annotation_proto(self, label: str, annotations: List, input_id: str,
|
|
91
|
+
dataset_id: str) -> resources_pb2.Annotation:
|
|
92
|
+
"""
|
|
93
|
+
Create an input proto for each bounding box, label input pair.
|
|
94
|
+
Args:
|
|
95
|
+
`label`: annotation label
|
|
96
|
+
`annotations`: a list of a single bbox's coordinates.
|
|
97
|
+
`input_id: unique input id
|
|
98
|
+
`dataset_id`: Clarifai dataset id
|
|
99
|
+
Returns:
|
|
100
|
+
An input proto representing a single image input
|
|
101
|
+
"""
|
|
102
|
+
input_annot_proto = resources_pb2.Annotation(
|
|
103
|
+
input_id=input_id,
|
|
104
|
+
data=resources_pb2.Data(regions=[
|
|
105
|
+
resources_pb2.Region(
|
|
106
|
+
region_info=resources_pb2.RegionInfo(bounding_box=resources_pb2.BoundingBox(
|
|
107
|
+
# Annotations ordering: [xmin, ymin, xmax, ymax]
|
|
108
|
+
# top_row must be less than bottom row
|
|
109
|
+
# left_col must be less than right col
|
|
110
|
+
top_row=annotations[1], #y_min
|
|
111
|
+
left_col=annotations[0], #x_min
|
|
112
|
+
bottom_row=annotations[3], #y_max
|
|
113
|
+
right_col=annotations[2] #x_max
|
|
114
|
+
)),
|
|
115
|
+
data=resources_pb2.Data(concepts=[
|
|
116
|
+
resources_pb2.Concept(
|
|
117
|
+
id=f"id-{''.join(label.split(' '))}", name=label, value=1.)
|
|
118
|
+
]))
|
|
119
|
+
]))
|
|
120
|
+
|
|
121
|
+
return input_annot_proto
|
|
122
|
+
|
|
123
|
+
def _get_input_protos(self) -> Tuple[Iterator, Iterator]:
|
|
124
|
+
"""
|
|
125
|
+
Create input image protos for each data generator item.
|
|
126
|
+
Returns:
|
|
127
|
+
Input and Annotation proto iterators.
|
|
128
|
+
"""
|
|
129
|
+
for i, item in tqdm(enumerate(self.datagen_object), desc="Creating input protos..."):
|
|
130
|
+
metadata = Struct()
|
|
131
|
+
image = item.image_path
|
|
132
|
+
labels = item.classes # list:[l1,...,ln]
|
|
133
|
+
bboxes = item.bboxes # [[xmin,ymin,xmax,ymax],...,[xmin,ymin,xmax,ymax]]
|
|
134
|
+
input_id = f"{self.dataset_id}-{self.split}-{i}" if item.id is None else f"{self.split}-{str(item.id)}"
|
|
135
|
+
metadata.update({"label": labels, "split": self.split})
|
|
136
|
+
|
|
137
|
+
input_image_proto = self.create_input_protos(image, input_id, self.dataset_id, metadata)
|
|
138
|
+
self._all_input_protos.append(input_image_proto)
|
|
139
|
+
|
|
140
|
+
# iter over bboxes and classes
|
|
141
|
+
# one id could have more than one bbox and label
|
|
142
|
+
for i in range(len(bboxes)):
|
|
143
|
+
input_annot_proto = self.create_annotation_proto(labels[i], bboxes[i], input_id,
|
|
144
|
+
self.dataset_id)
|
|
145
|
+
self._annotation_protos.append(input_annot_proto)
|
|
146
|
+
|
|
147
|
+
return iter(self._all_input_protos), iter(self._annotation_protos)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class VisualSegmentationDataset(ClarifaiDataset):
|
|
151
|
+
"""
|
|
152
|
+
Visual segmentation dataset proto class.
|
|
153
|
+
"""
|
|
154
|
+
|
|
155
|
+
def __init__(self, datagen_object: Iterator, dataset_id: str, split: str) -> None:
|
|
156
|
+
super().__init__(datagen_object, dataset_id, split)
|
|
157
|
+
self._mask_protos = [] # mask or polygon protos
|
|
158
|
+
|
|
159
|
+
def create_input_protos(self, image_path: str, input_id: str, dataset_id: str,
|
|
160
|
+
metadata: Struct) -> resources_pb2.Input:
|
|
161
|
+
"""
|
|
162
|
+
Create input protos for each image, label input pair.
|
|
163
|
+
Args:
|
|
164
|
+
`image_path`: absolute image file path
|
|
165
|
+
`input_id: unique input id
|
|
166
|
+
`dataset_id`: Clarifai dataset id
|
|
167
|
+
`metadata`: image metadata
|
|
168
|
+
Returns:
|
|
169
|
+
An input proto representing a single input item
|
|
170
|
+
"""
|
|
171
|
+
input_image_proto = resources_pb2.Input(
|
|
172
|
+
id=input_id,
|
|
173
|
+
dataset_ids=[dataset_id],
|
|
174
|
+
data=resources_pb2.Data(
|
|
175
|
+
image=resources_pb2.Image(base64=open(image_path, 'rb').read(),), metadata=metadata))
|
|
176
|
+
|
|
177
|
+
return input_image_proto
|
|
178
|
+
|
|
179
|
+
def create_mask_proto(self, label: str, polygons: List[List[float]], input_id: str,
|
|
180
|
+
dataset_id: str) -> resources_pb2.Annotation:
|
|
181
|
+
"""
|
|
182
|
+
Create an input mask proto for an input polygon/mask and label.
|
|
183
|
+
Args:
|
|
184
|
+
`label`: image label
|
|
185
|
+
`polygons`: Polygon x,y points iterable
|
|
186
|
+
`input_id: unique input id
|
|
187
|
+
`dataset_id`: Clarifai dataset id
|
|
188
|
+
Returns:
|
|
189
|
+
An input proto corresponding to a single image
|
|
190
|
+
"""
|
|
191
|
+
input_mask_proto = resources_pb2.Annotation(
|
|
192
|
+
input_id=input_id,
|
|
193
|
+
data=resources_pb2.Data(regions=[
|
|
194
|
+
resources_pb2.Region(
|
|
195
|
+
region_info=resources_pb2.RegionInfo(polygon=resources_pb2.Polygon(
|
|
196
|
+
points=[
|
|
197
|
+
resources_pb2.Point(
|
|
198
|
+
row=_point[1], # row is y point
|
|
199
|
+
col=_point[0], # col is x point
|
|
200
|
+
visibility="VISIBLE") for _point in polygons
|
|
201
|
+
])),
|
|
202
|
+
data=resources_pb2.Data(concepts=[
|
|
203
|
+
resources_pb2.Concept(
|
|
204
|
+
id=f"id-{''.join(label.split(' '))}", name=label, value=1.)
|
|
205
|
+
]))
|
|
206
|
+
]))
|
|
207
|
+
|
|
208
|
+
return input_mask_proto
|
|
209
|
+
|
|
210
|
+
def _get_input_protos(self) -> Tuple[Iterator, Iterator]:
|
|
211
|
+
"""
|
|
212
|
+
Create input image and annotation protos for each data generator item.
|
|
213
|
+
Returns:
|
|
214
|
+
Input and Annotation proto iterators.
|
|
215
|
+
"""
|
|
216
|
+
for i, item in tqdm(enumerate(self.datagen_object), desc="Creating input protos..."):
|
|
217
|
+
metadata = Struct()
|
|
218
|
+
image = item.image_path # image path
|
|
219
|
+
labels = item.classes # list of class labels
|
|
220
|
+
_polygons = item.polygons # list of polygons: [[[x,y],...,[x,y]],...]
|
|
221
|
+
input_id = f"{self.dataset_id}-{self.split}-{i}" if item.id is None else f"{self.split}-{str(item.id)}"
|
|
222
|
+
metadata.update({"label": labels, "split": self.split})
|
|
223
|
+
|
|
224
|
+
input_image_proto = self.create_input_protos(image, input_id, self.dataset_id, metadata)
|
|
225
|
+
self._all_input_protos.append(input_image_proto)
|
|
226
|
+
|
|
227
|
+
## Iterate over each masked image and create a proto for upload to clarifai
|
|
228
|
+
## The length of masks/polygons-list and labels must be equal
|
|
229
|
+
for i, _polygon in enumerate(_polygons):
|
|
230
|
+
try:
|
|
231
|
+
input_mask_proto = self.create_mask_proto(labels[i], _polygon, input_id, self.dataset_id)
|
|
232
|
+
self._mask_protos.append(input_mask_proto)
|
|
233
|
+
except IndexError:
|
|
234
|
+
continue
|
|
235
|
+
|
|
236
|
+
return iter(self._all_input_protos), iter(self._mask_protos)
|