clarifai 10.8.4__py3-none-any.whl → 10.8.6__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.
Files changed (61) hide show
  1. clarifai/__init__.py +1 -1
  2. clarifai/client/dataset.py +9 -3
  3. clarifai/constants/dataset.py +1 -1
  4. clarifai/datasets/upload/base.py +6 -3
  5. clarifai/datasets/upload/features.py +10 -0
  6. clarifai/datasets/upload/image.py +22 -13
  7. clarifai/datasets/upload/multimodal.py +70 -0
  8. clarifai/datasets/upload/text.py +8 -5
  9. clarifai/runners/models/model_upload.py +67 -31
  10. clarifai/runners/utils/loader.py +0 -1
  11. clarifai/utils/misc.py +6 -0
  12. {clarifai-10.8.4.dist-info → clarifai-10.8.6.dist-info}/METADATA +2 -1
  13. {clarifai-10.8.4.dist-info → clarifai-10.8.6.dist-info}/RECORD +17 -60
  14. clarifai/models/model_serving/README.md +0 -158
  15. clarifai/models/model_serving/__init__.py +0 -14
  16. clarifai/models/model_serving/cli/__init__.py +0 -12
  17. clarifai/models/model_serving/cli/_utils.py +0 -53
  18. clarifai/models/model_serving/cli/base.py +0 -14
  19. clarifai/models/model_serving/cli/build.py +0 -79
  20. clarifai/models/model_serving/cli/clarifai_clis.py +0 -33
  21. clarifai/models/model_serving/cli/create.py +0 -171
  22. clarifai/models/model_serving/cli/example_cli.py +0 -34
  23. clarifai/models/model_serving/cli/login.py +0 -26
  24. clarifai/models/model_serving/cli/upload.py +0 -183
  25. clarifai/models/model_serving/constants.py +0 -21
  26. clarifai/models/model_serving/docs/cli.md +0 -161
  27. clarifai/models/model_serving/docs/concepts.md +0 -229
  28. clarifai/models/model_serving/docs/dependencies.md +0 -11
  29. clarifai/models/model_serving/docs/inference_parameters.md +0 -139
  30. clarifai/models/model_serving/docs/model_types.md +0 -19
  31. clarifai/models/model_serving/model_config/__init__.py +0 -16
  32. clarifai/models/model_serving/model_config/base.py +0 -369
  33. clarifai/models/model_serving/model_config/config.py +0 -312
  34. clarifai/models/model_serving/model_config/inference_parameter.py +0 -129
  35. clarifai/models/model_serving/model_config/model_types_config/multimodal-embedder.yaml +0 -25
  36. clarifai/models/model_serving/model_config/model_types_config/text-classifier.yaml +0 -19
  37. clarifai/models/model_serving/model_config/model_types_config/text-embedder.yaml +0 -20
  38. clarifai/models/model_serving/model_config/model_types_config/text-to-image.yaml +0 -19
  39. clarifai/models/model_serving/model_config/model_types_config/text-to-text.yaml +0 -19
  40. clarifai/models/model_serving/model_config/model_types_config/visual-classifier.yaml +0 -22
  41. clarifai/models/model_serving/model_config/model_types_config/visual-detector.yaml +0 -32
  42. clarifai/models/model_serving/model_config/model_types_config/visual-embedder.yaml +0 -19
  43. clarifai/models/model_serving/model_config/model_types_config/visual-segmenter.yaml +0 -19
  44. clarifai/models/model_serving/model_config/output.py +0 -133
  45. clarifai/models/model_serving/model_config/triton/__init__.py +0 -14
  46. clarifai/models/model_serving/model_config/triton/serializer.py +0 -136
  47. clarifai/models/model_serving/model_config/triton/triton_config.py +0 -182
  48. clarifai/models/model_serving/model_config/triton/wrappers.py +0 -281
  49. clarifai/models/model_serving/repo_build/__init__.py +0 -14
  50. clarifai/models/model_serving/repo_build/build.py +0 -198
  51. clarifai/models/model_serving/repo_build/static_files/_requirements.txt +0 -2
  52. clarifai/models/model_serving/repo_build/static_files/base_test.py +0 -169
  53. clarifai/models/model_serving/repo_build/static_files/inference.py +0 -26
  54. clarifai/models/model_serving/repo_build/static_files/sample_clarifai_config.yaml +0 -25
  55. clarifai/models/model_serving/repo_build/static_files/test.py +0 -40
  56. clarifai/models/model_serving/repo_build/static_files/triton/model.py +0 -75
  57. clarifai/models/model_serving/utils.py +0 -31
  58. {clarifai-10.8.4.dist-info → clarifai-10.8.6.dist-info}/LICENSE +0 -0
  59. {clarifai-10.8.4.dist-info → clarifai-10.8.6.dist-info}/WHEEL +0 -0
  60. {clarifai-10.8.4.dist-info → clarifai-10.8.6.dist-info}/entry_points.txt +0 -0
  61. {clarifai-10.8.4.dist-info → clarifai-10.8.6.dist-info}/top_level.txt +0 -0
@@ -1,25 +0,0 @@
1
- # Sample config of inference_parameters and labels
2
- # For detail, please refer to docs
3
- # --------------------
4
- # inference_parameters:
5
- # - path: boolean_var
6
- # default_value: true
7
- # field_type: 1
8
- # description: a boolean variable
9
- # - path: string_var
10
- # default_value: "a string"
11
- # field_type: 2
12
- # description: a string variable
13
- # - path: number_var
14
- # default_value: 1
15
- # field_type: 3
16
- # description: a number variable
17
- # - path: secret_string_var
18
- # default_value: "YOUR_SECRET"
19
- # field_type: 21
20
- # description: a string variable contains secret like API key
21
- # labels:
22
- # - concept1
23
- # - concept2
24
- # - concept3
25
- # - concept4
@@ -1,40 +0,0 @@
1
- import unittest
2
-
3
- from clarifai.models.model_serving.repo_build import BaseTest
4
-
5
-
6
- class CustomTest(unittest.TestCase):
7
- """
8
- BaseTest loads the InferenceModel from the inference.py file in the current working directory.
9
- To execute the predict method of the InferenceModel, use the predict method in BaseTest.
10
- It takes the exact same inputs and inference parameters, returning the same outputs as InferenceModel.predict.
11
- The difference is that BaseTest.predict verifies your_infer_parameters against config.clarifai_models.inference_parameters and checks the output values.
12
-
13
- For example, test input value of visual-classifier
14
-
15
- def test_input(self):
16
- import cv2
17
- path = "path/to/image"
18
- img = cv2.imread(path)
19
- outputs = self.model.predict([img], infer_param1=..., infer_param2=...)
20
- print(outputs)
21
- assert outputs
22
-
23
- """
24
-
25
- def setUp(self) -> None:
26
- your_infer_parameter = dict(
27
- ) # for example dict(float_var=0.12, string_var="test", _secret_string_var="secret")
28
- self.model = BaseTest(your_infer_parameter)
29
-
30
- def test_default_cases(self):
31
- """Test your model with dummy inputs.
32
- In general, you only need to run this test to check your InferneceModel implementation.
33
- In case the default inputs makes your model failed for some reason (not because of assert in `test_with_default_inputs`),
34
- you can comment out this test.
35
- """
36
- self.model.test_with_default_inputs()
37
-
38
- def test_specific_case1(self):
39
- """ Implement your test case"""
40
- pass
@@ -1,75 +0,0 @@
1
- # Copyright 2023 Clarifai, Inc.
2
- # Licensed under the Apache License, Version 2.0 (the "License");
3
- # you may not use this file except in compliance with the License.
4
- # You may obtain a copy of the License at
5
- #
6
- # http://www.apache.org/licenses/LICENSE-2.0
7
- #
8
- # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an "AS IS" BASIS,
10
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- # See the License for the specific language governing permissions and
12
- # limitations under the License.
13
- """Triton inference server Python Backend Model."""
14
-
15
- import os
16
- import sys
17
-
18
- try:
19
- import triton_python_backend_utils as pb_utils
20
- except ModuleNotFoundError:
21
- pass
22
- from clarifai.models.model_serving.model_config.inference_parameter import parse_req_parameters
23
-
24
-
25
- class TritonPythonModel:
26
- """
27
- Triton Python BE Model.
28
- """
29
-
30
- def initialize(self, args):
31
- """
32
- Triton server init.
33
- """
34
- sys.path.append(os.path.dirname(__file__))
35
- from inference import InferenceModel
36
-
37
- self.inference_obj = InferenceModel()
38
-
39
- # Read input_name from config file
40
- self.input_names = [inp.name for inp in self.inference_obj.config.serving_backend.triton.input]
41
-
42
- def execute(self, requests):
43
- """
44
- Serve model inference requests.
45
- """
46
- responses = []
47
-
48
- for request in requests:
49
- try:
50
- parameters = request.parameters()
51
- except Exception:
52
- print(
53
- "It seems this triton version does not support `parameters()` in request. "
54
- "Please upgrade tritonserver version otherwise can not use `inference_parameters`. Error message: {e}"
55
- )
56
- parameters = None
57
-
58
- parameters = parse_req_parameters(parameters) if parameters else {}
59
-
60
- if len(self.input_names) == 1:
61
- in_batch = pb_utils.get_input_tensor_by_name(request, self.input_names[0])
62
- in_batch = in_batch.as_numpy()
63
- data = in_batch
64
- else:
65
- data = {}
66
- for input_name in self.input_names:
67
- in_batch = pb_utils.get_input_tensor_by_name(request, input_name)
68
- in_batch = in_batch.as_numpy() if in_batch is not None else []
69
- data.update({input_name: in_batch})
70
-
71
- inference_response = self.inference_obj._tritonserver_predict(
72
- input_data=data, inference_parameters=parameters)
73
- responses.append(inference_response)
74
-
75
- return responses
@@ -1,31 +0,0 @@
1
- import os
2
-
3
- from clarifai.models.model_serving.constants import CLARIFAI_PAT_PATH
4
- from clarifai.utils.constants import CLARIFAI_PAT_ENV_VAR
5
-
6
-
7
- def _persist_pat(pat: str):
8
- """ Write down pat to CLARIFAI_PAT_PATH """
9
- with open(CLARIFAI_PAT_PATH, "w") as f:
10
- f.write(pat)
11
-
12
-
13
- def _read_pat():
14
- if not os.path.exists(CLARIFAI_PAT_PATH) and not os.environ.get(CLARIFAI_PAT_ENV_VAR, ""):
15
- return None
16
- if os.path.exists(CLARIFAI_PAT_PATH):
17
- with open(CLARIFAI_PAT_PATH, "r") as f:
18
- return f.read().replace("\n", "").replace("\r", "").strip()
19
- elif os.environ.get(CLARIFAI_PAT_ENV_VAR):
20
- return os.environ.get(CLARIFAI_PAT_ENV_VAR)
21
- else:
22
- raise ValueError(
23
- f"PAT not found, please run `clarifai login` to persist your PAT or set it as an environment variable under the name '{CLARIFAI_PAT_ENV_VAR}'"
24
- )
25
-
26
-
27
- def login(pat=None):
28
- """ if pat provided, set pat to CLARIFAI_PAT otherwise read pat from file"""
29
- pat = pat or _read_pat()
30
- assert pat, Exception("PAT is not found, please run `clarifai login` to persist your PAT")
31
- os.environ["CLARIFAI_PAT"] = pat