clarifai 9.10.2__py3-none-any.whl → 9.10.3__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/client/__init__.py +3 -2
- clarifai/client/app.py +39 -23
- clarifai/client/base.py +6 -6
- clarifai/client/dataset.py +113 -55
- clarifai/client/input.py +47 -55
- clarifai/client/model.py +27 -25
- clarifai/client/module.py +13 -11
- clarifai/client/runner.py +5 -3
- clarifai/client/search.py +7 -3
- clarifai/client/user.py +14 -8
- clarifai/client/workflow.py +22 -20
- clarifai/constants/dataset.py +22 -0
- clarifai/datasets/upload/base.py +9 -7
- clarifai/datasets/upload/features.py +3 -3
- clarifai/datasets/upload/image.py +49 -50
- clarifai/datasets/upload/loaders/coco_captions.py +26 -80
- clarifai/datasets/upload/loaders/coco_detection.py +56 -115
- clarifai/datasets/upload/loaders/coco_segmentation.py +69 -137
- clarifai/datasets/upload/loaders/imagenet_classification.py +2 -3
- clarifai/datasets/upload/loaders/xview_detection.py +3 -3
- clarifai/datasets/upload/text.py +16 -16
- clarifai/datasets/upload/utils.py +196 -21
- clarifai/utils/misc.py +21 -0
- clarifai/versions.py +1 -1
- {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/METADATA +3 -3
- clarifai-9.10.3.dist-info/RECORD +96 -0
- clarifai-9.10.3.dist-info/top_level.txt +1 -0
- clarifai/auth/__init__.py +0 -6
- clarifai/auth/helper.py +0 -367
- clarifai/auth/register.py +0 -23
- clarifai/auth/stub.py +0 -127
- clarifai/datasets/upload/examples/README.md +0 -31
- clarifai/datasets/upload/examples/image_classification/__init__.py +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/__init__.py +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/cifar_small_test.csv +0 -10
- clarifai/datasets/upload/examples/image_classification/cifar10/cifar_small_train.csv +0 -10
- clarifai/datasets/upload/examples/image_classification/cifar10/dataset.py +0 -46
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_700.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_701.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_702.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_703.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_704.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_705.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_706.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_707.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_708.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_709.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/__init__.py +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/dataset.py +0 -39
- clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/1420783.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/3287885.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/3617075.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/38052.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/39147.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/139558.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/1636096.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/2480925.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/3385808.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/3647386.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/1826869.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/2243245.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/259212.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/2842688.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/3035414.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/1545393.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/2427642.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/3520891.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/377566.jpg +0 -0
- clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/503504.jpg +0 -0
- clarifai/datasets/upload/examples/text_classification/__init__.py +0 -0
- clarifai/datasets/upload/examples/text_classification/imdb_dataset/__init__.py +0 -0
- clarifai/datasets/upload/examples/text_classification/imdb_dataset/dataset.py +0 -42
- clarifai/datasets/upload/examples/text_classification/imdb_dataset/test.csv +0 -201
- clarifai/datasets/upload/examples/text_classification/imdb_dataset/train.csv +0 -201
- clarifai/datasets/upload/loaders/README.md +0 -49
- clarifai/models/model_serving/README.md +0 -155
- clarifai/models/model_serving/docs/custom_config.md +0 -33
- clarifai/models/model_serving/docs/dependencies.md +0 -11
- clarifai/models/model_serving/docs/inference_parameters.md +0 -134
- clarifai/models/model_serving/docs/model_types.md +0 -20
- clarifai/models/model_serving/docs/output.md +0 -28
- clarifai/models/model_serving/examples/README.md +0 -7
- clarifai/models/model_serving/examples/image_classification/README.md +0 -9
- clarifai/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/README.md +0 -11
- clarifai/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/config.json +0 -42
- clarifai/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/preprocessor_config.json +0 -15
- clarifai/models/model_serving/examples/image_classification/age_vit/config.pbtxt +0 -23
- clarifai/models/model_serving/examples/image_classification/age_vit/labels.txt +0 -9
- clarifai/models/model_serving/examples/image_classification/age_vit/requirements.txt +0 -7
- clarifai/models/model_serving/examples/text_classification/README.md +0 -9
- clarifai/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/README.md +0 -12
- clarifai/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/config.json +0 -34
- clarifai/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/special_tokens_map.json +0 -1
- clarifai/models/model_serving/examples/text_classification/xlm-roberta/config.pbtxt +0 -21
- clarifai/models/model_serving/examples/text_classification/xlm-roberta/labels.txt +0 -3
- clarifai/models/model_serving/examples/text_classification/xlm-roberta/requirements.txt +0 -7
- clarifai/models/model_serving/examples/text_embedding/README.md +0 -9
- clarifai/models/model_serving/examples/text_to_image/README.md +0 -9
- clarifai/models/model_serving/examples/text_to_image/sd-v1.5/1/__init__.py +0 -0
- clarifai/models/model_serving/examples/text_to_image/sd-v1.5/1/inference.py +0 -52
- clarifai/models/model_serving/examples/text_to_image/sd-v1.5/1/model.py +0 -60
- clarifai/models/model_serving/examples/text_to_image/sd-v1.5/config.pbtxt +0 -22
- clarifai/models/model_serving/examples/text_to_image/sd-v1.5/requirements.txt +0 -6
- clarifai/models/model_serving/examples/text_to_text/README.md +0 -10
- clarifai/models/model_serving/examples/text_to_text/bart-summarize/config.pbtxt +0 -20
- clarifai/models/model_serving/examples/text_to_text/bart-summarize/requirements.txt +0 -4
- clarifai/models/model_serving/examples/visual_detection/README.md +0 -11
- clarifai/models/model_serving/examples/visual_detection/yolov5x/config.pbtxt +0 -36
- clarifai/models/model_serving/examples/visual_detection/yolov5x/labels.txt +0 -80
- clarifai/models/model_serving/examples/visual_detection/yolov5x/requirements.txt +0 -12
- clarifai/models/model_serving/examples/visual_embedding/README.md +0 -9
- clarifai/models/model_serving/examples/visual_embedding/vit-base/config.pbtxt +0 -22
- clarifai/models/model_serving/examples/visual_embedding/vit-base/requirements.txt +0 -5
- clarifai/models/model_serving/examples/visual_segmentation/README.md +0 -9
- clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/config.pbtxt +0 -24
- clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/labels.txt +0 -18
- clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/requirements.txt +0 -5
- clarifai/models/model_serving/model_config/model_types_config/multimodal-embedder.yaml +0 -24
- clarifai/models/model_serving/model_config/model_types_config/text-classifier.yaml +0 -18
- clarifai/models/model_serving/model_config/model_types_config/text-embedder.yaml +0 -18
- clarifai/models/model_serving/model_config/model_types_config/text-to-image.yaml +0 -18
- clarifai/models/model_serving/model_config/model_types_config/text-to-text.yaml +0 -18
- clarifai/models/model_serving/model_config/model_types_config/visual-classifier.yaml +0 -18
- clarifai/models/model_serving/model_config/model_types_config/visual-detector.yaml +0 -28
- clarifai/models/model_serving/model_config/model_types_config/visual-embedder.yaml +0 -18
- clarifai/models/model_serving/model_config/model_types_config/visual-segmenter.yaml +0 -18
- clarifai/modules/README.md +0 -5
- clarifai/modules/style.css +0 -217
- clarifai-9.10.2.dist-info/RECORD +0 -386
- clarifai-9.10.2.dist-info/top_level.txt +0 -2
- clarifai_utils/__init__.py +0 -0
- clarifai_utils/auth/__init__.py +0 -6
- clarifai_utils/auth/helper.py +0 -367
- clarifai_utils/auth/register.py +0 -23
- clarifai_utils/auth/stub.py +0 -127
- clarifai_utils/cli.py +0 -0
- clarifai_utils/client/__init__.py +0 -16
- clarifai_utils/client/app.py +0 -684
- clarifai_utils/client/auth/__init__.py +0 -4
- clarifai_utils/client/auth/helper.py +0 -367
- clarifai_utils/client/auth/register.py +0 -23
- clarifai_utils/client/auth/stub.py +0 -127
- clarifai_utils/client/base.py +0 -131
- clarifai_utils/client/dataset.py +0 -442
- clarifai_utils/client/input.py +0 -892
- clarifai_utils/client/lister.py +0 -54
- clarifai_utils/client/model.py +0 -575
- clarifai_utils/client/module.py +0 -94
- clarifai_utils/client/runner.py +0 -161
- clarifai_utils/client/search.py +0 -254
- clarifai_utils/client/user.py +0 -253
- clarifai_utils/client/workflow.py +0 -223
- clarifai_utils/constants/model.py +0 -4
- clarifai_utils/constants/search.py +0 -2
- clarifai_utils/datasets/__init__.py +0 -0
- clarifai_utils/datasets/export/__init__.py +0 -0
- clarifai_utils/datasets/export/inputs_annotations.py +0 -222
- clarifai_utils/datasets/upload/__init__.py +0 -0
- clarifai_utils/datasets/upload/base.py +0 -66
- clarifai_utils/datasets/upload/examples/README.md +0 -31
- clarifai_utils/datasets/upload/examples/image_classification/__init__.py +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/__init__.py +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/cifar_small_test.csv +0 -10
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/cifar_small_train.csv +0 -10
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/dataset.py +0 -46
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_700.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_701.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_702.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_703.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_704.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_705.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_706.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_707.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_708.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_709.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/__init__.py +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/dataset.py +0 -39
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/1420783.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/3287885.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/3617075.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/38052.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/39147.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/139558.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/1636096.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/2480925.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/3385808.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/3647386.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/1826869.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/2243245.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/259212.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/2842688.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/3035414.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/1545393.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/2427642.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/3520891.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/377566.jpg +0 -0
- clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/503504.jpg +0 -0
- clarifai_utils/datasets/upload/examples/text_classification/__init__.py +0 -0
- clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/__init__.py +0 -0
- clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/dataset.py +0 -42
- clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/test.csv +0 -201
- clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/train.csv +0 -201
- clarifai_utils/datasets/upload/features.py +0 -44
- clarifai_utils/datasets/upload/image.py +0 -165
- clarifai_utils/datasets/upload/loaders/README.md +0 -49
- clarifai_utils/datasets/upload/loaders/__init__.py +0 -0
- clarifai_utils/datasets/upload/loaders/coco_captions.py +0 -103
- clarifai_utils/datasets/upload/loaders/coco_detection.py +0 -134
- clarifai_utils/datasets/upload/loaders/coco_segmentation.py +0 -166
- clarifai_utils/datasets/upload/loaders/imagenet_classification.py +0 -59
- clarifai_utils/datasets/upload/loaders/xview_detection.py +0 -148
- clarifai_utils/datasets/upload/text.py +0 -53
- clarifai_utils/datasets/upload/utils.py +0 -63
- clarifai_utils/errors.py +0 -89
- clarifai_utils/models/__init__.py +0 -0
- clarifai_utils/models/api.py +0 -283
- clarifai_utils/models/model_serving/README.md +0 -155
- clarifai_utils/models/model_serving/__init__.py +0 -12
- clarifai_utils/models/model_serving/cli/__init__.py +0 -12
- clarifai_utils/models/model_serving/cli/deploy_cli.py +0 -123
- clarifai_utils/models/model_serving/cli/model_zip.py +0 -61
- clarifai_utils/models/model_serving/cli/repository.py +0 -87
- clarifai_utils/models/model_serving/constants.py +0 -1
- clarifai_utils/models/model_serving/docs/custom_config.md +0 -33
- clarifai_utils/models/model_serving/docs/dependencies.md +0 -11
- clarifai_utils/models/model_serving/docs/inference_parameters.md +0 -134
- clarifai_utils/models/model_serving/docs/model_types.md +0 -20
- clarifai_utils/models/model_serving/docs/output.md +0 -28
- clarifai_utils/models/model_serving/examples/README.md +0 -7
- clarifai_utils/models/model_serving/examples/image_classification/README.md +0 -9
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/__init__.py +0 -0
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/inference.py +0 -56
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/model.py +0 -61
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/README.md +0 -11
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/config.json +0 -42
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/preprocessor_config.json +0 -15
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/config.pbtxt +0 -23
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/labels.txt +0 -9
- clarifai_utils/models/model_serving/examples/image_classification/age_vit/requirements.txt +0 -7
- clarifai_utils/models/model_serving/examples/text_classification/README.md +0 -9
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/__init__.py +0 -0
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/inference.py +0 -55
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/model.py +0 -61
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/README.md +0 -12
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/config.json +0 -34
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/special_tokens_map.json +0 -1
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/config.pbtxt +0 -21
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/labels.txt +0 -3
- clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/requirements.txt +0 -7
- clarifai_utils/models/model_serving/examples/text_embedding/README.md +0 -9
- clarifai_utils/models/model_serving/examples/text_to_image/README.md +0 -9
- clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/1/__init__.py +0 -0
- clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/1/inference.py +0 -52
- clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/1/model.py +0 -60
- clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/config.pbtxt +0 -22
- clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/requirements.txt +0 -6
- clarifai_utils/models/model_serving/examples/text_to_text/README.md +0 -10
- clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/1/__init__.py +0 -0
- clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/1/inference.py +0 -47
- clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/1/model.py +0 -60
- clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/config.pbtxt +0 -20
- clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/requirements.txt +0 -4
- clarifai_utils/models/model_serving/examples/visual_detection/README.md +0 -11
- clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/1/inference.py +0 -72
- clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/1/model.py +0 -61
- clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/config.pbtxt +0 -36
- clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/labels.txt +0 -80
- clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/requirements.txt +0 -12
- clarifai_utils/models/model_serving/examples/visual_embedding/README.md +0 -9
- clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/1/__init__.py +0 -0
- clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/1/inference.py +0 -51
- clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/1/model.py +0 -60
- clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/config.pbtxt +0 -22
- clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/requirements.txt +0 -5
- clarifai_utils/models/model_serving/examples/visual_segmentation/README.md +0 -9
- clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/1/__init__.py +0 -0
- clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/1/inference.py +0 -55
- clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/1/model.py +0 -60
- clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/config.pbtxt +0 -24
- clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/labels.txt +0 -18
- clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/requirements.txt +0 -5
- clarifai_utils/models/model_serving/model_config/__init__.py +0 -14
- clarifai_utils/models/model_serving/model_config/config.py +0 -302
- clarifai_utils/models/model_serving/model_config/inference_parameter.py +0 -124
- clarifai_utils/models/model_serving/model_config/model_types_config/multimodal-embedder.yaml +0 -24
- clarifai_utils/models/model_serving/model_config/model_types_config/text-classifier.yaml +0 -18
- clarifai_utils/models/model_serving/model_config/model_types_config/text-embedder.yaml +0 -18
- clarifai_utils/models/model_serving/model_config/model_types_config/text-to-image.yaml +0 -18
- clarifai_utils/models/model_serving/model_config/model_types_config/text-to-text.yaml +0 -18
- clarifai_utils/models/model_serving/model_config/model_types_config/visual-classifier.yaml +0 -18
- clarifai_utils/models/model_serving/model_config/model_types_config/visual-detector.yaml +0 -28
- clarifai_utils/models/model_serving/model_config/model_types_config/visual-embedder.yaml +0 -18
- clarifai_utils/models/model_serving/model_config/model_types_config/visual-segmenter.yaml +0 -18
- clarifai_utils/models/model_serving/model_config/serializer.py +0 -134
- clarifai_utils/models/model_serving/models/__init__.py +0 -12
- clarifai_utils/models/model_serving/models/default_test.py +0 -275
- clarifai_utils/models/model_serving/models/inference.py +0 -42
- clarifai_utils/models/model_serving/models/model_types.py +0 -265
- clarifai_utils/models/model_serving/models/output.py +0 -124
- clarifai_utils/models/model_serving/models/pb_model.py +0 -74
- clarifai_utils/models/model_serving/models/test.py +0 -64
- clarifai_utils/models/model_serving/pb_model_repository.py +0 -101
- clarifai_utils/modules/README.md +0 -5
- clarifai_utils/modules/__init__.py +0 -0
- clarifai_utils/modules/css.py +0 -60
- clarifai_utils/modules/pages.py +0 -42
- clarifai_utils/modules/style.css +0 -217
- clarifai_utils/runners/__init__.py +0 -0
- clarifai_utils/runners/example.py +0 -33
- clarifai_utils/schema/search.py +0 -69
- clarifai_utils/urls/helper.py +0 -103
- clarifai_utils/utils/__init__.py +0 -0
- clarifai_utils/utils/logging.py +0 -90
- clarifai_utils/utils/misc.py +0 -33
- clarifai_utils/utils/model_train.py +0 -157
- clarifai_utils/versions.py +0 -6
- clarifai_utils/workflows/__init__.py +0 -0
- clarifai_utils/workflows/export.py +0 -68
- clarifai_utils/workflows/utils.py +0 -59
- clarifai_utils/workflows/validate.py +0 -67
- {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/LICENSE +0 -0
- {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/WHEEL +0 -0
- {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/entry_points.txt +0 -0
clarifai/client/input.py
CHANGED
|
@@ -25,10 +25,11 @@ class Inputs(Lister, BaseClient):
|
|
|
25
25
|
"""Inputs is a class that provides access to Clarifai API endpoints related to Input information."""
|
|
26
26
|
|
|
27
27
|
def __init__(self,
|
|
28
|
-
user_id: str =
|
|
29
|
-
app_id: str =
|
|
28
|
+
user_id: str = None,
|
|
29
|
+
app_id: str = None,
|
|
30
30
|
logger_level: str = "INFO",
|
|
31
31
|
base_url: str = "https://api.clarifai.com",
|
|
32
|
+
pat: str = None,
|
|
32
33
|
**kwargs):
|
|
33
34
|
"""Initializes an Input object.
|
|
34
35
|
|
|
@@ -43,11 +44,11 @@ class Inputs(Lister, BaseClient):
|
|
|
43
44
|
self.kwargs = {**kwargs}
|
|
44
45
|
self.input_info = resources_pb2.Input(**self.kwargs)
|
|
45
46
|
self.logger = get_logger(logger_level=logger_level, name=__name__)
|
|
46
|
-
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id, base=base_url)
|
|
47
|
+
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id, base=base_url, pat=pat)
|
|
47
48
|
Lister.__init__(self)
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
@staticmethod
|
|
51
|
+
def _get_proto(input_id: str,
|
|
51
52
|
dataset_id: Union[str, None],
|
|
52
53
|
imagepb: Image = None,
|
|
53
54
|
video_pb: Video = None,
|
|
@@ -106,8 +107,8 @@ class Inputs(Lister, BaseClient):
|
|
|
106
107
|
concepts=concepts,
|
|
107
108
|
metadata=metadata))
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
@staticmethod
|
|
111
|
+
def get_input_from_url(input_id: str,
|
|
111
112
|
image_url: str = None,
|
|
112
113
|
video_url: str = None,
|
|
113
114
|
audio_url: str = None,
|
|
@@ -129,8 +130,7 @@ class Inputs(Lister, BaseClient):
|
|
|
129
130
|
|
|
130
131
|
Example:
|
|
131
132
|
>>> from clarifai.client.input import Inputs
|
|
132
|
-
>>>
|
|
133
|
-
>>> input_proto = input_obj.get_input_from_url(input_id = 'demo', image_url='https://samples.clarifai.com/metro-north.jpg')
|
|
133
|
+
>>> input_proto = Inputs.get_input_from_url(input_id = 'demo', image_url='https://samples.clarifai.com/metro-north.jpg')
|
|
134
134
|
"""
|
|
135
135
|
if not any((image_url, video_url, audio_url, text_url)):
|
|
136
136
|
raise ValueError(
|
|
@@ -139,7 +139,7 @@ class Inputs(Lister, BaseClient):
|
|
|
139
139
|
video_pb = resources_pb2.Video(url=video_url) if video_url else None
|
|
140
140
|
audio_pb = resources_pb2.Audio(url=audio_url) if audio_url else None
|
|
141
141
|
text_pb = resources_pb2.Text(url=text_url) if text_url else None
|
|
142
|
-
return
|
|
142
|
+
return Inputs._get_proto(
|
|
143
143
|
input_id=input_id,
|
|
144
144
|
dataset_id=dataset_id,
|
|
145
145
|
imagepb=image_pb,
|
|
@@ -148,8 +148,8 @@ class Inputs(Lister, BaseClient):
|
|
|
148
148
|
text_pb=text_pb,
|
|
149
149
|
**kwargs)
|
|
150
150
|
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
@staticmethod
|
|
152
|
+
def get_input_from_file(input_id: str,
|
|
153
153
|
image_file: str = None,
|
|
154
154
|
video_file: str = None,
|
|
155
155
|
audio_file: str = None,
|
|
@@ -171,8 +171,7 @@ class Inputs(Lister, BaseClient):
|
|
|
171
171
|
|
|
172
172
|
Example:
|
|
173
173
|
>>> from clarifai.client.input import Inputs
|
|
174
|
-
>>>
|
|
175
|
-
>>> input_proto = input_obj.get_input_from_file(input_id = 'demo', video_file='file_path')
|
|
174
|
+
>>> input_proto = Inputs.get_input_from_file(input_id = 'demo', video_file='file_path')
|
|
176
175
|
"""
|
|
177
176
|
if not any((image_file, video_file, audio_file, text_file)):
|
|
178
177
|
raise ValueError(
|
|
@@ -181,7 +180,7 @@ class Inputs(Lister, BaseClient):
|
|
|
181
180
|
video_pb = resources_pb2.Video(base64=open(video_file, 'rb').read()) if video_file else None
|
|
182
181
|
audio_pb = resources_pb2.Audio(base64=open(audio_file, 'rb').read()) if audio_file else None
|
|
183
182
|
text_pb = resources_pb2.Text(raw=open(text_file, 'rb').read()) if text_file else None
|
|
184
|
-
return
|
|
183
|
+
return Inputs._get_proto(
|
|
185
184
|
input_id=input_id,
|
|
186
185
|
dataset_id=dataset_id,
|
|
187
186
|
imagepb=image_pb,
|
|
@@ -190,8 +189,8 @@ class Inputs(Lister, BaseClient):
|
|
|
190
189
|
text_pb=text_pb,
|
|
191
190
|
**kwargs)
|
|
192
191
|
|
|
193
|
-
|
|
194
|
-
|
|
192
|
+
@staticmethod
|
|
193
|
+
def get_input_from_bytes(input_id: str,
|
|
195
194
|
image_bytes: bytes = None,
|
|
196
195
|
video_bytes: bytes = None,
|
|
197
196
|
audio_bytes: bytes = None,
|
|
@@ -213,10 +212,9 @@ class Inputs(Lister, BaseClient):
|
|
|
213
212
|
|
|
214
213
|
Example:
|
|
215
214
|
>>> from clarifai.client.input import Inputs
|
|
216
|
-
>>> input_obj = Inputs()
|
|
217
215
|
>>> image = open('demo.jpg', 'rb').read()
|
|
218
216
|
>>> video = open('demo.mp4', 'rb').read()
|
|
219
|
-
>>> input_proto =
|
|
217
|
+
>>> input_proto = Inputs.get_input_from_bytes(input_id = 'demo',image_bytes =image, video_bytes=video)
|
|
220
218
|
"""
|
|
221
219
|
if not any((image_bytes, video_bytes, audio_bytes, text_bytes)):
|
|
222
220
|
raise ValueError(
|
|
@@ -225,7 +223,7 @@ class Inputs(Lister, BaseClient):
|
|
|
225
223
|
video_pb = resources_pb2.Video(base64=video_bytes) if video_bytes else None
|
|
226
224
|
audio_pb = resources_pb2.Audio(base64=audio_bytes) if audio_bytes else None
|
|
227
225
|
text_pb = resources_pb2.Text(raw=text_bytes) if text_bytes else None
|
|
228
|
-
return
|
|
226
|
+
return Inputs._get_proto(
|
|
229
227
|
input_id=input_id,
|
|
230
228
|
dataset_id=dataset_id,
|
|
231
229
|
imagepb=image_pb,
|
|
@@ -234,9 +232,8 @@ class Inputs(Lister, BaseClient):
|
|
|
234
232
|
text_pb=text_pb,
|
|
235
233
|
**kwargs)
|
|
236
234
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
dataset_id: str = None,
|
|
235
|
+
@staticmethod
|
|
236
|
+
def get_image_inputs_from_folder(folder_path: str, dataset_id: str = None,
|
|
240
237
|
labels: bool = False) -> List[Input]: #image specific
|
|
241
238
|
"""Create input protos for image data type from folder.
|
|
242
239
|
|
|
@@ -248,8 +245,7 @@ class Inputs(Lister, BaseClient):
|
|
|
248
245
|
|
|
249
246
|
Example:
|
|
250
247
|
>>> from clarifai.client.input import Inputs
|
|
251
|
-
>>>
|
|
252
|
-
>>> input_protos = input_obj.get_image_inputs_from_folder(folder_path='demo_folder')
|
|
248
|
+
>>> input_protos = Inputs.get_image_inputs_from_folder(folder_path='demo_folder')
|
|
253
249
|
"""
|
|
254
250
|
input_protos = []
|
|
255
251
|
labels = [folder_path.split('/')[-1]] if labels else None
|
|
@@ -259,11 +255,12 @@ class Inputs(Lister, BaseClient):
|
|
|
259
255
|
input_id = filename.split('.')[0]
|
|
260
256
|
image_pb = resources_pb2.Image(base64=open(os.path.join(folder_path, filename), 'rb').read())
|
|
261
257
|
input_protos.append(
|
|
262
|
-
|
|
258
|
+
Inputs._get_proto(
|
|
263
259
|
input_id=input_id, dataset_id=dataset_id, imagepb=image_pb, labels=labels))
|
|
264
260
|
return input_protos
|
|
265
261
|
|
|
266
|
-
|
|
262
|
+
@staticmethod
|
|
263
|
+
def get_text_input(input_id: str, raw_text: str, dataset_id: str = None,
|
|
267
264
|
**kwargs) -> Text: #text specific
|
|
268
265
|
"""Create input proto for text data type from rawtext.
|
|
269
266
|
|
|
@@ -278,14 +275,13 @@ class Inputs(Lister, BaseClient):
|
|
|
278
275
|
|
|
279
276
|
Example:
|
|
280
277
|
>>> from clarifai.client.input import Inputs
|
|
281
|
-
>>>
|
|
282
|
-
>>> input_protos = input_obj.get_text_input(input_id = 'demo', raw_text = 'This is a test')
|
|
278
|
+
>>> input_protos = Inputs.get_text_input(input_id = 'demo', raw_text = 'This is a test')
|
|
283
279
|
"""
|
|
284
280
|
text_pb = resources_pb2.Text(raw=raw_text)
|
|
285
|
-
return
|
|
281
|
+
return Inputs._get_proto(input_id=input_id, dataset_id=dataset_id, text_pb=text_pb, **kwargs)
|
|
286
282
|
|
|
287
|
-
|
|
288
|
-
|
|
283
|
+
@staticmethod
|
|
284
|
+
def get_inputs_from_csv(csv_path: str,
|
|
289
285
|
input_type: str = 'text',
|
|
290
286
|
csv_type: str = 'raw',
|
|
291
287
|
dataset_id: str = None,
|
|
@@ -304,8 +300,7 @@ class Inputs(Lister, BaseClient):
|
|
|
304
300
|
|
|
305
301
|
Example:
|
|
306
302
|
>>> from clarifai.client.input import Inputs
|
|
307
|
-
>>>
|
|
308
|
-
>>> input_protos = input_obj.get_inputs_from_csv(csv_path='filepath', input_type='text', csv_type='raw')
|
|
303
|
+
>>> input_protos = Inputs.get_inputs_from_csv(csv_path='filepath', input_type='text', csv_type='raw')
|
|
309
304
|
"""
|
|
310
305
|
input_protos = []
|
|
311
306
|
with open(csv_path) as _file:
|
|
@@ -356,7 +351,7 @@ class Inputs(Lister, BaseClient):
|
|
|
356
351
|
|
|
357
352
|
if csv_type == 'raw':
|
|
358
353
|
input_protos.append(
|
|
359
|
-
|
|
354
|
+
Inputs.get_text_input(
|
|
360
355
|
input_id=input_id,
|
|
361
356
|
raw_text=text,
|
|
362
357
|
dataset_id=dataset_id,
|
|
@@ -365,7 +360,7 @@ class Inputs(Lister, BaseClient):
|
|
|
365
360
|
geo_info=geo_info))
|
|
366
361
|
elif csv_type == 'url':
|
|
367
362
|
input_protos.append(
|
|
368
|
-
|
|
363
|
+
Inputs.get_input_from_url(
|
|
369
364
|
input_id=input_id,
|
|
370
365
|
image_url=image,
|
|
371
366
|
text_url=text,
|
|
@@ -377,7 +372,7 @@ class Inputs(Lister, BaseClient):
|
|
|
377
372
|
geo_info=geo_info))
|
|
378
373
|
else:
|
|
379
374
|
input_protos.append(
|
|
380
|
-
|
|
375
|
+
Inputs.get_input_from_file(
|
|
381
376
|
input_id=input_id,
|
|
382
377
|
image_file=image,
|
|
383
378
|
text_file=text,
|
|
@@ -390,9 +385,8 @@ class Inputs(Lister, BaseClient):
|
|
|
390
385
|
|
|
391
386
|
return input_protos
|
|
392
387
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
dataset_id: str = None,
|
|
388
|
+
@staticmethod
|
|
389
|
+
def get_text_inputs_from_folder(folder_path: str, dataset_id: str = None,
|
|
396
390
|
labels: bool = False) -> List[Text]: #text specific
|
|
397
391
|
"""Create input protos for text data type from folder.
|
|
398
392
|
|
|
@@ -404,8 +398,7 @@ class Inputs(Lister, BaseClient):
|
|
|
404
398
|
|
|
405
399
|
Example:
|
|
406
400
|
>>> from clarifai.client.input import Inputs
|
|
407
|
-
>>>
|
|
408
|
-
>>> input_protos = input_obj.get_text_inputs_from_folder(folder_path='demo_folder')
|
|
401
|
+
>>> input_protos = Inputs.get_text_inputs_from_folder(folder_path='demo_folder')
|
|
409
402
|
"""
|
|
410
403
|
input_protos = []
|
|
411
404
|
labels = [folder_path.split('/')[-1]] if labels else None
|
|
@@ -415,11 +408,12 @@ class Inputs(Lister, BaseClient):
|
|
|
415
408
|
input_id = filename.split('.')[0]
|
|
416
409
|
text_pb = resources_pb2.Text(raw=open(os.path.join(folder_path, filename), 'rb').read())
|
|
417
410
|
input_protos.append(
|
|
418
|
-
|
|
411
|
+
Inputs._get_proto(
|
|
419
412
|
input_id=input_id, dataset_id=dataset_id, text_pb=text_pb, labels=labels))
|
|
420
413
|
return input_protos
|
|
421
414
|
|
|
422
|
-
|
|
415
|
+
@staticmethod
|
|
416
|
+
def get_annotation_proto(input_id: str, label: str, annotations: List) -> Annotation:
|
|
423
417
|
"""Create an annotation proto for each bounding box, label input pair.
|
|
424
418
|
|
|
425
419
|
Args:
|
|
@@ -432,8 +426,7 @@ class Inputs(Lister, BaseClient):
|
|
|
432
426
|
|
|
433
427
|
Example:
|
|
434
428
|
>>> from clarifai.client.input import Inputs
|
|
435
|
-
>>>
|
|
436
|
-
>>> input_obj.get_annotation_proto(input_id='demo', label='demo', annotations=[x_min, y_min, x_max, y_max])
|
|
429
|
+
>>> Inputs.get_annotation_proto(input_id='demo', label='demo', annotations=[x_min, y_min, x_max, y_max])
|
|
437
430
|
"""
|
|
438
431
|
if not isinstance(annotations, list):
|
|
439
432
|
raise UserError("annotations must be a list of bbox cooridnates")
|
|
@@ -458,7 +451,8 @@ class Inputs(Lister, BaseClient):
|
|
|
458
451
|
|
|
459
452
|
return input_annot_proto
|
|
460
453
|
|
|
461
|
-
|
|
454
|
+
@staticmethod
|
|
455
|
+
def get_mask_proto(input_id: str, label: str, polygons: List[List[float]]) -> Annotation:
|
|
462
456
|
"""Create an annotation proto for each polygon box, label input pair.
|
|
463
457
|
|
|
464
458
|
Args:
|
|
@@ -471,8 +465,7 @@ class Inputs(Lister, BaseClient):
|
|
|
471
465
|
|
|
472
466
|
Example:
|
|
473
467
|
>>> from clarifai.client.input import Inputs
|
|
474
|
-
>>>
|
|
475
|
-
>>> input_obj.get_mask_proto(input_id='demo', label='demo', polygons=[[[x,y],...,[x,y]],...])
|
|
468
|
+
>>> Inputs.get_mask_proto(input_id='demo', label='demo', polygons=[[[x,y],...,[x,y]],...])
|
|
476
469
|
"""
|
|
477
470
|
if not isinstance(polygons, list):
|
|
478
471
|
raise UserError("polygons must be a list of points")
|
|
@@ -653,8 +646,7 @@ class Inputs(Lister, BaseClient):
|
|
|
653
646
|
response = self._grpc_request(self.STUB.PostAnnotations, request)
|
|
654
647
|
if response.status.code != status_code_pb2.SUCCESS:
|
|
655
648
|
try:
|
|
656
|
-
self.logger.warning(
|
|
657
|
-
f"Post annotations failed, status: {response.annotations[0].status.details}")
|
|
649
|
+
self.logger.warning(f"Post annotations failed, status: {response.annotations[0].status}")
|
|
658
650
|
except Exception:
|
|
659
651
|
self.logger.warning(f"Post annotations failed, status: {response.status.details}")
|
|
660
652
|
finally:
|
|
@@ -788,16 +780,16 @@ class Inputs(Lister, BaseClient):
|
|
|
788
780
|
annotations_info['id'] = annotations_info.pop('annotation_id')
|
|
789
781
|
yield Annotation(**annotations_info)
|
|
790
782
|
|
|
791
|
-
def _bulk_upload(self, inputs: List[Input],
|
|
783
|
+
def _bulk_upload(self, inputs: List[Input], batch_size: int = 128) -> None:
|
|
792
784
|
"""Uploads process for large number of inputs.
|
|
793
785
|
|
|
794
786
|
Args:
|
|
795
787
|
inputs (List[Input]): input protos
|
|
796
|
-
|
|
788
|
+
batch_size (int): batch size for each request
|
|
797
789
|
"""
|
|
798
790
|
num_workers: int = min(10, cpu_count()) # limit max workers to 10
|
|
799
|
-
|
|
800
|
-
chunked_inputs = Chunker(inputs,
|
|
791
|
+
batch_size = min(128, batch_size) # limit max protos in a req
|
|
792
|
+
chunked_inputs = Chunker(inputs, batch_size).chunk()
|
|
801
793
|
with ThreadPoolExecutor(max_workers=num_workers) as executor:
|
|
802
794
|
with tqdm(total=len(chunked_inputs), desc='Uploading inputs') as progress:
|
|
803
795
|
# Submit all jobs to the executor and store the returned futures
|
clarifai/client/model.py
CHANGED
|
@@ -27,34 +27,35 @@ class Model(Lister, BaseClient):
|
|
|
27
27
|
"""Model is a class that provides access to Clarifai API endpoints related to Model information."""
|
|
28
28
|
|
|
29
29
|
def __init__(self,
|
|
30
|
-
|
|
31
|
-
model_id: str =
|
|
30
|
+
url: str = None,
|
|
31
|
+
model_id: str = None,
|
|
32
32
|
model_version: Dict = {'id': ""},
|
|
33
33
|
base_url: str = "https://api.clarifai.com",
|
|
34
|
+
pat: str = None,
|
|
34
35
|
**kwargs):
|
|
35
36
|
"""Initializes a Model object.
|
|
36
37
|
|
|
37
38
|
Args:
|
|
38
|
-
|
|
39
|
+
url (str): The URL to initialize the model object.
|
|
39
40
|
model_id (str): The Model ID to interact with.
|
|
40
41
|
model_version (dict): The Model Version to interact with.
|
|
41
42
|
base_url (str): Base API url. Default "https://api.clarifai.com"
|
|
43
|
+
pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
|
|
42
44
|
**kwargs: Additional keyword arguments to be passed to the Model.
|
|
43
45
|
"""
|
|
44
|
-
if
|
|
45
|
-
raise UserError("You can only specify one of
|
|
46
|
-
if
|
|
47
|
-
raise UserError("You must specify one of
|
|
48
|
-
if
|
|
49
|
-
user_id, app_id, _, model_id, model_version_id = ClarifaiUrlHelper.split_clarifai_url(
|
|
50
|
-
url_init)
|
|
46
|
+
if url and model_id:
|
|
47
|
+
raise UserError("You can only specify one of url or model_id.")
|
|
48
|
+
if not url and not model_id:
|
|
49
|
+
raise UserError("You must specify one of url or model_id.")
|
|
50
|
+
if url:
|
|
51
|
+
user_id, app_id, _, model_id, model_version_id = ClarifaiUrlHelper.split_clarifai_url(url)
|
|
51
52
|
model_version = {'id': model_version_id}
|
|
52
53
|
kwargs = {'user_id': user_id, 'app_id': app_id}
|
|
53
54
|
self.kwargs = {**kwargs, 'id': model_id, 'model_version': model_version,}
|
|
54
55
|
self.model_info = resources_pb2.Model(**self.kwargs)
|
|
55
56
|
self.logger = get_logger(logger_level="INFO")
|
|
56
57
|
self.training_params = {}
|
|
57
|
-
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id, base=base_url)
|
|
58
|
+
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id, base=base_url, pat=pat)
|
|
58
59
|
Lister.__init__(self)
|
|
59
60
|
|
|
60
61
|
def list_training_templates(self) -> List[str]:
|
|
@@ -306,7 +307,7 @@ class Model(Lister, BaseClient):
|
|
|
306
307
|
|
|
307
308
|
Example:
|
|
308
309
|
>>> from clarifai.client.model import Model
|
|
309
|
-
>>> model = Model("
|
|
310
|
+
>>> model = Model("url")
|
|
310
311
|
or
|
|
311
312
|
>>> model = Model(model_id='model_id', user_id='user_id', app_id='app_id')
|
|
312
313
|
>>> model_version = model.create_version(description='model_version_description')
|
|
@@ -330,7 +331,7 @@ class Model(Lister, BaseClient):
|
|
|
330
331
|
dict_response = MessageToDict(response, preserving_proto_field_name=True)
|
|
331
332
|
kwargs = self.process_response_keys(dict_response['model'], 'model')
|
|
332
333
|
|
|
333
|
-
return Model(base_url=self.base, **kwargs)
|
|
334
|
+
return Model(base_url=self.base, pat=self.pat, **kwargs)
|
|
334
335
|
|
|
335
336
|
def list_versions(self, page_no: int = None,
|
|
336
337
|
per_page: int = None) -> Generator['Model', None, None]:
|
|
@@ -345,7 +346,7 @@ class Model(Lister, BaseClient):
|
|
|
345
346
|
|
|
346
347
|
Example:
|
|
347
348
|
>>> from clarifai.client.model import Model
|
|
348
|
-
>>> model = Model("
|
|
349
|
+
>>> model = Model("url") # Example URL: https://clarifai.com/clarifai/main/models/general-image-recognition
|
|
349
350
|
or
|
|
350
351
|
>>> model = Model(model_id='model_id', user_id='user_id', app_id='app_id')
|
|
351
352
|
>>> all_model_versions = list(model.list_versions())
|
|
@@ -375,6 +376,7 @@ class Model(Lister, BaseClient):
|
|
|
375
376
|
yield Model(
|
|
376
377
|
model_id=self.id,
|
|
377
378
|
base_url=self.base,
|
|
379
|
+
pat=self.pat,
|
|
378
380
|
**dict(self.kwargs, model_version=model_version_info))
|
|
379
381
|
|
|
380
382
|
def predict(self, inputs: List[Input], inference_params: Dict = {}, output_config: Dict = {}):
|
|
@@ -432,7 +434,7 @@ class Model(Lister, BaseClient):
|
|
|
432
434
|
|
|
433
435
|
Example:
|
|
434
436
|
>>> from clarifai.client.model import Model
|
|
435
|
-
>>> model = Model("
|
|
437
|
+
>>> model = Model("url") # Example URL: https://clarifai.com/clarifai/main/models/general-image-recognition
|
|
436
438
|
or
|
|
437
439
|
>>> model = Model(model_id='model_id', user_id='user_id', app_id='app_id')
|
|
438
440
|
>>> model_prediction = model.predict_by_filepath('/path/to/image.jpg', 'image')
|
|
@@ -476,13 +478,13 @@ class Model(Lister, BaseClient):
|
|
|
476
478
|
raise UserError('Invalid bytes.')
|
|
477
479
|
|
|
478
480
|
if input_type == "image":
|
|
479
|
-
input_proto = Inputs
|
|
481
|
+
input_proto = Inputs.get_input_from_bytes("", image_bytes=input_bytes)
|
|
480
482
|
elif input_type == "text":
|
|
481
|
-
input_proto = Inputs
|
|
483
|
+
input_proto = Inputs.get_input_from_bytes("", text_bytes=input_bytes)
|
|
482
484
|
elif input_type == "video":
|
|
483
|
-
input_proto = Inputs
|
|
485
|
+
input_proto = Inputs.get_input_from_bytes("", video_bytes=input_bytes)
|
|
484
486
|
elif input_type == "audio":
|
|
485
|
-
input_proto = Inputs
|
|
487
|
+
input_proto = Inputs.get_input_from_bytes("", audio_bytes=input_bytes)
|
|
486
488
|
|
|
487
489
|
return self.predict(
|
|
488
490
|
inputs=[input_proto], inference_params=inference_params, output_config=output_config)
|
|
@@ -505,7 +507,7 @@ class Model(Lister, BaseClient):
|
|
|
505
507
|
|
|
506
508
|
Example:
|
|
507
509
|
>>> from clarifai.client.model import Model
|
|
508
|
-
>>> model = Model("
|
|
510
|
+
>>> model = Model("url") # Example URL: https://clarifai.com/clarifai/main/models/general-image-recognition
|
|
509
511
|
or
|
|
510
512
|
>>> model = Model(model_id='model_id', user_id='user_id', app_id='app_id')
|
|
511
513
|
>>> model_prediction = model.predict_by_url('url', 'image')
|
|
@@ -515,13 +517,13 @@ class Model(Lister, BaseClient):
|
|
|
515
517
|
f"Got input type {input_type} but expected one of image, text, video, audio.")
|
|
516
518
|
|
|
517
519
|
if input_type == "image":
|
|
518
|
-
input_proto = Inputs
|
|
520
|
+
input_proto = Inputs.get_input_from_url("", image_url=url)
|
|
519
521
|
elif input_type == "text":
|
|
520
|
-
input_proto = Inputs
|
|
522
|
+
input_proto = Inputs.get_input_from_url("", text_url=url)
|
|
521
523
|
elif input_type == "video":
|
|
522
|
-
input_proto = Inputs
|
|
524
|
+
input_proto = Inputs.get_input_from_url("", video_url=url)
|
|
523
525
|
elif input_type == "audio":
|
|
524
|
-
input_proto = Inputs
|
|
526
|
+
input_proto = Inputs.get_input_from_url("", audio_url=url)
|
|
525
527
|
|
|
526
528
|
return self.predict(
|
|
527
529
|
inputs=[input_proto], inference_params=inference_params, output_config=output_config)
|
|
@@ -537,8 +539,8 @@ class Model(Lister, BaseClient):
|
|
|
537
539
|
select_concepts (list[Concept]): The concepts to select.
|
|
538
540
|
sample_ms (int): The number of milliseconds to sample.
|
|
539
541
|
"""
|
|
542
|
+
params = Struct()
|
|
540
543
|
if inference_params is not None:
|
|
541
|
-
params = Struct()
|
|
542
544
|
params.update(inference_params)
|
|
543
545
|
|
|
544
546
|
self.model_info.model_version.output_info.CopyFrom(
|
clarifai/client/module.py
CHANGED
|
@@ -13,34 +13,35 @@ class Module(Lister, BaseClient):
|
|
|
13
13
|
"""Module is a class that provides access to Clarifai API endpoints related to Module information."""
|
|
14
14
|
|
|
15
15
|
def __init__(self,
|
|
16
|
-
|
|
17
|
-
module_id: str =
|
|
16
|
+
url: str = None,
|
|
17
|
+
module_id: str = None,
|
|
18
18
|
module_version: Dict = {'id': ""},
|
|
19
19
|
base_url: str = "https://api.clarifai.com",
|
|
20
|
+
pat: str = None,
|
|
20
21
|
**kwargs):
|
|
21
22
|
"""Initializes a Module object.
|
|
22
23
|
|
|
23
24
|
Args:
|
|
24
|
-
|
|
25
|
+
url (str): The URL to initialize the module object.
|
|
25
26
|
module_id (str): The Module ID to interact with.
|
|
26
27
|
module_version (dict): The Module Version to interact with.
|
|
27
28
|
base_url (str): Base API url. Default "https://api.clarifai.com"
|
|
29
|
+
pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
|
|
28
30
|
**kwargs: Additional keyword arguments to be passed to the Module.
|
|
29
31
|
"""
|
|
30
|
-
if
|
|
31
|
-
raise UserError("You can only specify one of
|
|
32
|
-
if
|
|
33
|
-
raise UserError("You must specify one of
|
|
34
|
-
if
|
|
35
|
-
user_id, app_id, module_id, module_version_id = ClarifaiUrlHelper.split_module_ui_url(
|
|
36
|
-
url_init)
|
|
32
|
+
if url and module_id:
|
|
33
|
+
raise UserError("You can only specify one of url or module_id.")
|
|
34
|
+
if not url and not module_id:
|
|
35
|
+
raise UserError("You must specify one of url or module_id.")
|
|
36
|
+
if url:
|
|
37
|
+
user_id, app_id, module_id, module_version_id = ClarifaiUrlHelper.split_module_ui_url(url)
|
|
37
38
|
module_version = {'id': module_version_id}
|
|
38
39
|
kwargs = {'user_id': user_id, 'app_id': app_id}
|
|
39
40
|
|
|
40
41
|
self.kwargs = {**kwargs, 'id': module_id, 'module_version': module_version}
|
|
41
42
|
self.module_info = resources_pb2.Module(**self.kwargs)
|
|
42
43
|
self.logger = get_logger(logger_level="INFO")
|
|
43
|
-
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id, base=base_url)
|
|
44
|
+
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id, base=base_url, pat=pat)
|
|
44
45
|
Lister.__init__(self)
|
|
45
46
|
|
|
46
47
|
def list_versions(self, page_no: int = None,
|
|
@@ -80,6 +81,7 @@ class Module(Lister, BaseClient):
|
|
|
80
81
|
yield Module(
|
|
81
82
|
module_id=self.id,
|
|
82
83
|
base_url=self.base,
|
|
84
|
+
pat=self.pat,
|
|
83
85
|
**dict(self.kwargs, module_version=module_version_info))
|
|
84
86
|
|
|
85
87
|
def __getattr__(self, name):
|
clarifai/client/runner.py
CHANGED
|
@@ -32,19 +32,21 @@ class Runner(BaseClient):
|
|
|
32
32
|
|
|
33
33
|
def __init__(self,
|
|
34
34
|
runner_id: str,
|
|
35
|
-
user_id: str =
|
|
35
|
+
user_id: str = None,
|
|
36
36
|
check_runner_exists: bool = True,
|
|
37
37
|
base_url: str = "https://api.clarifai.com",
|
|
38
|
+
pat: str = None,
|
|
38
39
|
**kwargs) -> None:
|
|
39
40
|
"""
|
|
40
41
|
Args:
|
|
41
42
|
runner_id (str): the id of the runner to use. Create the runner in the Clarifai API first
|
|
42
43
|
user_id (str): Clarifai User ID
|
|
43
44
|
base_url (str): Base API url. Default "https://api.clarifai.com"
|
|
45
|
+
pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
|
|
44
46
|
"""
|
|
45
47
|
user_id = user_id or os.environ.get("CLARIFAI_USER_ID", "")
|
|
46
48
|
|
|
47
|
-
if user_id
|
|
49
|
+
if not user_id:
|
|
48
50
|
raise UserError(
|
|
49
51
|
"Set CLARIFAI_USER_ID as environment variables or pass user_id as input arguments")
|
|
50
52
|
|
|
@@ -52,7 +54,7 @@ class Runner(BaseClient):
|
|
|
52
54
|
self.logger = get_logger("INFO", __name__)
|
|
53
55
|
self.kwargs = {**kwargs, 'id': runner_id, 'user_id': user_id}
|
|
54
56
|
self.runner_info = resources_pb2.Runner(**self.kwargs)
|
|
55
|
-
BaseClient.__init__(self, user_id=self.user_id, app_id="", base=base_url)
|
|
57
|
+
BaseClient.__init__(self, user_id=self.user_id, app_id="", base=base_url, pat=pat)
|
|
56
58
|
|
|
57
59
|
# Check that the runner exists.
|
|
58
60
|
if check_runner_exists:
|
clarifai/client/search.py
CHANGED
|
@@ -21,7 +21,9 @@ class Search(Lister, BaseClient):
|
|
|
21
21
|
user_id,
|
|
22
22
|
app_id,
|
|
23
23
|
top_k: int = DEFAULT_TOP_K,
|
|
24
|
-
metric: str = DEFAULT_SEARCH_METRIC
|
|
24
|
+
metric: str = DEFAULT_SEARCH_METRIC,
|
|
25
|
+
base_url: str = "https://api.clarifai.com",
|
|
26
|
+
pat: str = None):
|
|
25
27
|
"""Initialize the Search object.
|
|
26
28
|
|
|
27
29
|
Args:
|
|
@@ -29,6 +31,8 @@ class Search(Lister, BaseClient):
|
|
|
29
31
|
app_id (str): App ID.
|
|
30
32
|
top_k (int, optional): Top K results to retrieve. Defaults to 10.
|
|
31
33
|
metric (str, optional): Similarity metric (either 'cosine' or 'euclidean'). Defaults to 'cosine'.
|
|
34
|
+
base_url (str, optional): Base API url. Defaults to "https://api.clarifai.com".
|
|
35
|
+
pat (str, optional): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
|
|
32
36
|
|
|
33
37
|
Raises:
|
|
34
38
|
UserError: If the metric is not 'cosine' or 'euclidean'.
|
|
@@ -42,9 +46,9 @@ class Search(Lister, BaseClient):
|
|
|
42
46
|
self.data_proto = resources_pb2.Data()
|
|
43
47
|
self.top_k = top_k
|
|
44
48
|
|
|
45
|
-
self.inputs = Inputs(user_id=self.user_id, app_id=self.app_id)
|
|
49
|
+
self.inputs = Inputs(user_id=self.user_id, app_id=self.app_id, pat=pat)
|
|
46
50
|
self.rank_filter_schema = get_schema()
|
|
47
|
-
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id)
|
|
51
|
+
BaseClient.__init__(self, user_id=self.user_id, app_id=self.app_id, base=base_url, pat=pat)
|
|
48
52
|
Lister.__init__(self, page_size=1000)
|
|
49
53
|
|
|
50
54
|
def _get_annot_proto(self, **kwargs):
|
clarifai/client/user.py
CHANGED
|
@@ -15,18 +15,23 @@ from clarifai.utils.logging import get_logger
|
|
|
15
15
|
class User(Lister, BaseClient):
|
|
16
16
|
"""User is a class that provides access to Clarifai API endpoints related to user information."""
|
|
17
17
|
|
|
18
|
-
def __init__(self,
|
|
18
|
+
def __init__(self,
|
|
19
|
+
user_id: str = None,
|
|
20
|
+
base_url: str = "https://api.clarifai.com",
|
|
21
|
+
pat: str = None,
|
|
22
|
+
**kwargs):
|
|
19
23
|
"""Initializes an User object.
|
|
20
24
|
|
|
21
25
|
Args:
|
|
22
26
|
user_id (str): The user ID for the user to interact with.
|
|
23
27
|
base_url (str): Base API url. Default "https://api.clarifai.com"
|
|
28
|
+
pat (str): A personal access token for authentication. Can be set as env var CLARIFAI_PAT
|
|
24
29
|
**kwargs: Additional keyword arguments to be passed to the User.
|
|
25
30
|
"""
|
|
26
31
|
self.kwargs = {**kwargs, 'id': user_id}
|
|
27
32
|
self.user_info = resources_pb2.User(**self.kwargs)
|
|
28
33
|
self.logger = get_logger(logger_level="INFO", name=__name__)
|
|
29
|
-
BaseClient.__init__(self, user_id=self.id, app_id="", base=base_url)
|
|
34
|
+
BaseClient.__init__(self, user_id=self.id, app_id="", base=base_url, pat=pat)
|
|
30
35
|
Lister.__init__(self)
|
|
31
36
|
|
|
32
37
|
def list_apps(self, filter_by: Dict[str, Any] = {}, page_no: int = None,
|
|
@@ -57,7 +62,7 @@ class User(Lister, BaseClient):
|
|
|
57
62
|
per_page=per_page,
|
|
58
63
|
page_no=page_no)
|
|
59
64
|
for app_info in all_apps_info:
|
|
60
|
-
yield App(base_url=self.base, **app_info)
|
|
65
|
+
yield App(base_url=self.base, pat=self.pat, **app_info)
|
|
61
66
|
|
|
62
67
|
def list_runners(self, filter_by: Dict[str, Any] = {}, page_no: int = None,
|
|
63
68
|
per_page: int = None) -> Generator[Runner, None, None]:
|
|
@@ -89,7 +94,7 @@ class User(Lister, BaseClient):
|
|
|
89
94
|
page_no=page_no)
|
|
90
95
|
|
|
91
96
|
for runner_info in all_runners_info:
|
|
92
|
-
yield Runner(check_runner_exists=False, base_url=self.base, **runner_info)
|
|
97
|
+
yield Runner(check_runner_exists=False, base_url=self.base, pat=self.pat, **runner_info)
|
|
93
98
|
|
|
94
99
|
def create_app(self, app_id: str, base_workflow: str = 'Empty', **kwargs) -> App:
|
|
95
100
|
"""Creates an app for the user.
|
|
@@ -115,7 +120,7 @@ class User(Lister, BaseClient):
|
|
|
115
120
|
if response.status.code != status_code_pb2.SUCCESS:
|
|
116
121
|
raise Exception(response.status)
|
|
117
122
|
self.logger.info("\nApp created\n%s", response.status)
|
|
118
|
-
kwargs.update({'user_id': self.id, 'base_url': self.base})
|
|
123
|
+
kwargs.update({'user_id': self.id, 'base_url': self.base, 'pat': self.pat})
|
|
119
124
|
return App(app_id=app_id, **kwargs)
|
|
120
125
|
|
|
121
126
|
def create_runner(self, runner_id: str, labels: List[str], description: str) -> Runner:
|
|
@@ -152,7 +157,8 @@ class User(Lister, BaseClient):
|
|
|
152
157
|
labels=labels,
|
|
153
158
|
description=description,
|
|
154
159
|
check_runner_exists=False,
|
|
155
|
-
base_url=self.base
|
|
160
|
+
base_url=self.base,
|
|
161
|
+
pat=self.pat)
|
|
156
162
|
|
|
157
163
|
def app(self, app_id: str, **kwargs) -> App:
|
|
158
164
|
"""Returns an App object for the specified app ID.
|
|
@@ -175,7 +181,7 @@ class User(Lister, BaseClient):
|
|
|
175
181
|
raise Exception(response.status)
|
|
176
182
|
|
|
177
183
|
kwargs['user_id'] = self.id
|
|
178
|
-
kwargs.update({'base_url': self.base})
|
|
184
|
+
kwargs.update({'base_url': self.base, 'pat': self.pat})
|
|
179
185
|
return App(app_id=app_id, **kwargs)
|
|
180
186
|
|
|
181
187
|
def runner(self, runner_id: str) -> Runner:
|
|
@@ -204,7 +210,7 @@ class User(Lister, BaseClient):
|
|
|
204
210
|
kwargs = self.process_response_keys(dict_response[list(dict_response.keys())[1]],
|
|
205
211
|
list(dict_response.keys())[1])
|
|
206
212
|
|
|
207
|
-
return Runner(check_runner_exists=False, base_url=self.base, **kwargs)
|
|
213
|
+
return Runner(check_runner_exists=False, base_url=self.base, pat=self.pat, **kwargs)
|
|
208
214
|
|
|
209
215
|
def delete_app(self, app_id: str) -> None:
|
|
210
216
|
"""Deletes an app for the user.
|