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.
Files changed (323) hide show
  1. clarifai/client/__init__.py +3 -2
  2. clarifai/client/app.py +39 -23
  3. clarifai/client/base.py +6 -6
  4. clarifai/client/dataset.py +113 -55
  5. clarifai/client/input.py +47 -55
  6. clarifai/client/model.py +27 -25
  7. clarifai/client/module.py +13 -11
  8. clarifai/client/runner.py +5 -3
  9. clarifai/client/search.py +7 -3
  10. clarifai/client/user.py +14 -8
  11. clarifai/client/workflow.py +22 -20
  12. clarifai/constants/dataset.py +22 -0
  13. clarifai/datasets/upload/base.py +9 -7
  14. clarifai/datasets/upload/features.py +3 -3
  15. clarifai/datasets/upload/image.py +49 -50
  16. clarifai/datasets/upload/loaders/coco_captions.py +26 -80
  17. clarifai/datasets/upload/loaders/coco_detection.py +56 -115
  18. clarifai/datasets/upload/loaders/coco_segmentation.py +69 -137
  19. clarifai/datasets/upload/loaders/imagenet_classification.py +2 -3
  20. clarifai/datasets/upload/loaders/xview_detection.py +3 -3
  21. clarifai/datasets/upload/text.py +16 -16
  22. clarifai/datasets/upload/utils.py +196 -21
  23. clarifai/utils/misc.py +21 -0
  24. clarifai/versions.py +1 -1
  25. {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/METADATA +3 -3
  26. clarifai-9.10.3.dist-info/RECORD +96 -0
  27. clarifai-9.10.3.dist-info/top_level.txt +1 -0
  28. clarifai/auth/__init__.py +0 -6
  29. clarifai/auth/helper.py +0 -367
  30. clarifai/auth/register.py +0 -23
  31. clarifai/auth/stub.py +0 -127
  32. clarifai/datasets/upload/examples/README.md +0 -31
  33. clarifai/datasets/upload/examples/image_classification/__init__.py +0 -0
  34. clarifai/datasets/upload/examples/image_classification/cifar10/__init__.py +0 -0
  35. clarifai/datasets/upload/examples/image_classification/cifar10/cifar_small_test.csv +0 -10
  36. clarifai/datasets/upload/examples/image_classification/cifar10/cifar_small_train.csv +0 -10
  37. clarifai/datasets/upload/examples/image_classification/cifar10/dataset.py +0 -46
  38. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_700.jpg +0 -0
  39. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_701.jpg +0 -0
  40. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_702.jpg +0 -0
  41. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_703.jpg +0 -0
  42. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_704.jpg +0 -0
  43. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_705.jpg +0 -0
  44. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_706.jpg +0 -0
  45. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_707.jpg +0 -0
  46. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_708.jpg +0 -0
  47. clarifai/datasets/upload/examples/image_classification/cifar10/images/test_batch_709.jpg +0 -0
  48. clarifai/datasets/upload/examples/image_classification/food-101/__init__.py +0 -0
  49. clarifai/datasets/upload/examples/image_classification/food-101/dataset.py +0 -39
  50. clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/1420783.jpg +0 -0
  51. clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/3287885.jpg +0 -0
  52. clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/3617075.jpg +0 -0
  53. clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/38052.jpg +0 -0
  54. clarifai/datasets/upload/examples/image_classification/food-101/images/beignets/39147.jpg +0 -0
  55. clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/139558.jpg +0 -0
  56. clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/1636096.jpg +0 -0
  57. clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/2480925.jpg +0 -0
  58. clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/3385808.jpg +0 -0
  59. clarifai/datasets/upload/examples/image_classification/food-101/images/hamburger/3647386.jpg +0 -0
  60. clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/1826869.jpg +0 -0
  61. clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/2243245.jpg +0 -0
  62. clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/259212.jpg +0 -0
  63. clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/2842688.jpg +0 -0
  64. clarifai/datasets/upload/examples/image_classification/food-101/images/prime_rib/3035414.jpg +0 -0
  65. clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/1545393.jpg +0 -0
  66. clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/2427642.jpg +0 -0
  67. clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/3520891.jpg +0 -0
  68. clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/377566.jpg +0 -0
  69. clarifai/datasets/upload/examples/image_classification/food-101/images/ramen/503504.jpg +0 -0
  70. clarifai/datasets/upload/examples/text_classification/__init__.py +0 -0
  71. clarifai/datasets/upload/examples/text_classification/imdb_dataset/__init__.py +0 -0
  72. clarifai/datasets/upload/examples/text_classification/imdb_dataset/dataset.py +0 -42
  73. clarifai/datasets/upload/examples/text_classification/imdb_dataset/test.csv +0 -201
  74. clarifai/datasets/upload/examples/text_classification/imdb_dataset/train.csv +0 -201
  75. clarifai/datasets/upload/loaders/README.md +0 -49
  76. clarifai/models/model_serving/README.md +0 -155
  77. clarifai/models/model_serving/docs/custom_config.md +0 -33
  78. clarifai/models/model_serving/docs/dependencies.md +0 -11
  79. clarifai/models/model_serving/docs/inference_parameters.md +0 -134
  80. clarifai/models/model_serving/docs/model_types.md +0 -20
  81. clarifai/models/model_serving/docs/output.md +0 -28
  82. clarifai/models/model_serving/examples/README.md +0 -7
  83. clarifai/models/model_serving/examples/image_classification/README.md +0 -9
  84. clarifai/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/README.md +0 -11
  85. clarifai/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/config.json +0 -42
  86. clarifai/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/preprocessor_config.json +0 -15
  87. clarifai/models/model_serving/examples/image_classification/age_vit/config.pbtxt +0 -23
  88. clarifai/models/model_serving/examples/image_classification/age_vit/labels.txt +0 -9
  89. clarifai/models/model_serving/examples/image_classification/age_vit/requirements.txt +0 -7
  90. clarifai/models/model_serving/examples/text_classification/README.md +0 -9
  91. clarifai/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/README.md +0 -12
  92. clarifai/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/config.json +0 -34
  93. clarifai/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/special_tokens_map.json +0 -1
  94. clarifai/models/model_serving/examples/text_classification/xlm-roberta/config.pbtxt +0 -21
  95. clarifai/models/model_serving/examples/text_classification/xlm-roberta/labels.txt +0 -3
  96. clarifai/models/model_serving/examples/text_classification/xlm-roberta/requirements.txt +0 -7
  97. clarifai/models/model_serving/examples/text_embedding/README.md +0 -9
  98. clarifai/models/model_serving/examples/text_to_image/README.md +0 -9
  99. clarifai/models/model_serving/examples/text_to_image/sd-v1.5/1/__init__.py +0 -0
  100. clarifai/models/model_serving/examples/text_to_image/sd-v1.5/1/inference.py +0 -52
  101. clarifai/models/model_serving/examples/text_to_image/sd-v1.5/1/model.py +0 -60
  102. clarifai/models/model_serving/examples/text_to_image/sd-v1.5/config.pbtxt +0 -22
  103. clarifai/models/model_serving/examples/text_to_image/sd-v1.5/requirements.txt +0 -6
  104. clarifai/models/model_serving/examples/text_to_text/README.md +0 -10
  105. clarifai/models/model_serving/examples/text_to_text/bart-summarize/config.pbtxt +0 -20
  106. clarifai/models/model_serving/examples/text_to_text/bart-summarize/requirements.txt +0 -4
  107. clarifai/models/model_serving/examples/visual_detection/README.md +0 -11
  108. clarifai/models/model_serving/examples/visual_detection/yolov5x/config.pbtxt +0 -36
  109. clarifai/models/model_serving/examples/visual_detection/yolov5x/labels.txt +0 -80
  110. clarifai/models/model_serving/examples/visual_detection/yolov5x/requirements.txt +0 -12
  111. clarifai/models/model_serving/examples/visual_embedding/README.md +0 -9
  112. clarifai/models/model_serving/examples/visual_embedding/vit-base/config.pbtxt +0 -22
  113. clarifai/models/model_serving/examples/visual_embedding/vit-base/requirements.txt +0 -5
  114. clarifai/models/model_serving/examples/visual_segmentation/README.md +0 -9
  115. clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/config.pbtxt +0 -24
  116. clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/labels.txt +0 -18
  117. clarifai/models/model_serving/examples/visual_segmentation/segformer-b2/requirements.txt +0 -5
  118. clarifai/models/model_serving/model_config/model_types_config/multimodal-embedder.yaml +0 -24
  119. clarifai/models/model_serving/model_config/model_types_config/text-classifier.yaml +0 -18
  120. clarifai/models/model_serving/model_config/model_types_config/text-embedder.yaml +0 -18
  121. clarifai/models/model_serving/model_config/model_types_config/text-to-image.yaml +0 -18
  122. clarifai/models/model_serving/model_config/model_types_config/text-to-text.yaml +0 -18
  123. clarifai/models/model_serving/model_config/model_types_config/visual-classifier.yaml +0 -18
  124. clarifai/models/model_serving/model_config/model_types_config/visual-detector.yaml +0 -28
  125. clarifai/models/model_serving/model_config/model_types_config/visual-embedder.yaml +0 -18
  126. clarifai/models/model_serving/model_config/model_types_config/visual-segmenter.yaml +0 -18
  127. clarifai/modules/README.md +0 -5
  128. clarifai/modules/style.css +0 -217
  129. clarifai-9.10.2.dist-info/RECORD +0 -386
  130. clarifai-9.10.2.dist-info/top_level.txt +0 -2
  131. clarifai_utils/__init__.py +0 -0
  132. clarifai_utils/auth/__init__.py +0 -6
  133. clarifai_utils/auth/helper.py +0 -367
  134. clarifai_utils/auth/register.py +0 -23
  135. clarifai_utils/auth/stub.py +0 -127
  136. clarifai_utils/cli.py +0 -0
  137. clarifai_utils/client/__init__.py +0 -16
  138. clarifai_utils/client/app.py +0 -684
  139. clarifai_utils/client/auth/__init__.py +0 -4
  140. clarifai_utils/client/auth/helper.py +0 -367
  141. clarifai_utils/client/auth/register.py +0 -23
  142. clarifai_utils/client/auth/stub.py +0 -127
  143. clarifai_utils/client/base.py +0 -131
  144. clarifai_utils/client/dataset.py +0 -442
  145. clarifai_utils/client/input.py +0 -892
  146. clarifai_utils/client/lister.py +0 -54
  147. clarifai_utils/client/model.py +0 -575
  148. clarifai_utils/client/module.py +0 -94
  149. clarifai_utils/client/runner.py +0 -161
  150. clarifai_utils/client/search.py +0 -254
  151. clarifai_utils/client/user.py +0 -253
  152. clarifai_utils/client/workflow.py +0 -223
  153. clarifai_utils/constants/model.py +0 -4
  154. clarifai_utils/constants/search.py +0 -2
  155. clarifai_utils/datasets/__init__.py +0 -0
  156. clarifai_utils/datasets/export/__init__.py +0 -0
  157. clarifai_utils/datasets/export/inputs_annotations.py +0 -222
  158. clarifai_utils/datasets/upload/__init__.py +0 -0
  159. clarifai_utils/datasets/upload/base.py +0 -66
  160. clarifai_utils/datasets/upload/examples/README.md +0 -31
  161. clarifai_utils/datasets/upload/examples/image_classification/__init__.py +0 -0
  162. clarifai_utils/datasets/upload/examples/image_classification/cifar10/__init__.py +0 -0
  163. clarifai_utils/datasets/upload/examples/image_classification/cifar10/cifar_small_test.csv +0 -10
  164. clarifai_utils/datasets/upload/examples/image_classification/cifar10/cifar_small_train.csv +0 -10
  165. clarifai_utils/datasets/upload/examples/image_classification/cifar10/dataset.py +0 -46
  166. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_700.jpg +0 -0
  167. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_701.jpg +0 -0
  168. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_702.jpg +0 -0
  169. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_703.jpg +0 -0
  170. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_704.jpg +0 -0
  171. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_705.jpg +0 -0
  172. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_706.jpg +0 -0
  173. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_707.jpg +0 -0
  174. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_708.jpg +0 -0
  175. clarifai_utils/datasets/upload/examples/image_classification/cifar10/images/test_batch_709.jpg +0 -0
  176. clarifai_utils/datasets/upload/examples/image_classification/food-101/__init__.py +0 -0
  177. clarifai_utils/datasets/upload/examples/image_classification/food-101/dataset.py +0 -39
  178. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/1420783.jpg +0 -0
  179. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/3287885.jpg +0 -0
  180. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/3617075.jpg +0 -0
  181. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/38052.jpg +0 -0
  182. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/beignets/39147.jpg +0 -0
  183. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/139558.jpg +0 -0
  184. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/1636096.jpg +0 -0
  185. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/2480925.jpg +0 -0
  186. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/3385808.jpg +0 -0
  187. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/hamburger/3647386.jpg +0 -0
  188. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/1826869.jpg +0 -0
  189. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/2243245.jpg +0 -0
  190. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/259212.jpg +0 -0
  191. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/2842688.jpg +0 -0
  192. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/prime_rib/3035414.jpg +0 -0
  193. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/1545393.jpg +0 -0
  194. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/2427642.jpg +0 -0
  195. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/3520891.jpg +0 -0
  196. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/377566.jpg +0 -0
  197. clarifai_utils/datasets/upload/examples/image_classification/food-101/images/ramen/503504.jpg +0 -0
  198. clarifai_utils/datasets/upload/examples/text_classification/__init__.py +0 -0
  199. clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/__init__.py +0 -0
  200. clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/dataset.py +0 -42
  201. clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/test.csv +0 -201
  202. clarifai_utils/datasets/upload/examples/text_classification/imdb_dataset/train.csv +0 -201
  203. clarifai_utils/datasets/upload/features.py +0 -44
  204. clarifai_utils/datasets/upload/image.py +0 -165
  205. clarifai_utils/datasets/upload/loaders/README.md +0 -49
  206. clarifai_utils/datasets/upload/loaders/__init__.py +0 -0
  207. clarifai_utils/datasets/upload/loaders/coco_captions.py +0 -103
  208. clarifai_utils/datasets/upload/loaders/coco_detection.py +0 -134
  209. clarifai_utils/datasets/upload/loaders/coco_segmentation.py +0 -166
  210. clarifai_utils/datasets/upload/loaders/imagenet_classification.py +0 -59
  211. clarifai_utils/datasets/upload/loaders/xview_detection.py +0 -148
  212. clarifai_utils/datasets/upload/text.py +0 -53
  213. clarifai_utils/datasets/upload/utils.py +0 -63
  214. clarifai_utils/errors.py +0 -89
  215. clarifai_utils/models/__init__.py +0 -0
  216. clarifai_utils/models/api.py +0 -283
  217. clarifai_utils/models/model_serving/README.md +0 -155
  218. clarifai_utils/models/model_serving/__init__.py +0 -12
  219. clarifai_utils/models/model_serving/cli/__init__.py +0 -12
  220. clarifai_utils/models/model_serving/cli/deploy_cli.py +0 -123
  221. clarifai_utils/models/model_serving/cli/model_zip.py +0 -61
  222. clarifai_utils/models/model_serving/cli/repository.py +0 -87
  223. clarifai_utils/models/model_serving/constants.py +0 -1
  224. clarifai_utils/models/model_serving/docs/custom_config.md +0 -33
  225. clarifai_utils/models/model_serving/docs/dependencies.md +0 -11
  226. clarifai_utils/models/model_serving/docs/inference_parameters.md +0 -134
  227. clarifai_utils/models/model_serving/docs/model_types.md +0 -20
  228. clarifai_utils/models/model_serving/docs/output.md +0 -28
  229. clarifai_utils/models/model_serving/examples/README.md +0 -7
  230. clarifai_utils/models/model_serving/examples/image_classification/README.md +0 -9
  231. clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/__init__.py +0 -0
  232. clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/inference.py +0 -56
  233. clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/model.py +0 -61
  234. clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/README.md +0 -11
  235. clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/config.json +0 -42
  236. clarifai_utils/models/model_serving/examples/image_classification/age_vit/1/vit-age-classifier/preprocessor_config.json +0 -15
  237. clarifai_utils/models/model_serving/examples/image_classification/age_vit/config.pbtxt +0 -23
  238. clarifai_utils/models/model_serving/examples/image_classification/age_vit/labels.txt +0 -9
  239. clarifai_utils/models/model_serving/examples/image_classification/age_vit/requirements.txt +0 -7
  240. clarifai_utils/models/model_serving/examples/text_classification/README.md +0 -9
  241. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/__init__.py +0 -0
  242. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/inference.py +0 -55
  243. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/model.py +0 -61
  244. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/README.md +0 -12
  245. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/config.json +0 -34
  246. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/1/twitter-xlm-roberta-base-sentiment/special_tokens_map.json +0 -1
  247. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/config.pbtxt +0 -21
  248. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/labels.txt +0 -3
  249. clarifai_utils/models/model_serving/examples/text_classification/xlm-roberta/requirements.txt +0 -7
  250. clarifai_utils/models/model_serving/examples/text_embedding/README.md +0 -9
  251. clarifai_utils/models/model_serving/examples/text_to_image/README.md +0 -9
  252. clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/1/__init__.py +0 -0
  253. clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/1/inference.py +0 -52
  254. clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/1/model.py +0 -60
  255. clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/config.pbtxt +0 -22
  256. clarifai_utils/models/model_serving/examples/text_to_image/sd-v1.5/requirements.txt +0 -6
  257. clarifai_utils/models/model_serving/examples/text_to_text/README.md +0 -10
  258. clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/1/__init__.py +0 -0
  259. clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/1/inference.py +0 -47
  260. clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/1/model.py +0 -60
  261. clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/config.pbtxt +0 -20
  262. clarifai_utils/models/model_serving/examples/text_to_text/bart-summarize/requirements.txt +0 -4
  263. clarifai_utils/models/model_serving/examples/visual_detection/README.md +0 -11
  264. clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/1/inference.py +0 -72
  265. clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/1/model.py +0 -61
  266. clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/config.pbtxt +0 -36
  267. clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/labels.txt +0 -80
  268. clarifai_utils/models/model_serving/examples/visual_detection/yolov5x/requirements.txt +0 -12
  269. clarifai_utils/models/model_serving/examples/visual_embedding/README.md +0 -9
  270. clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/1/__init__.py +0 -0
  271. clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/1/inference.py +0 -51
  272. clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/1/model.py +0 -60
  273. clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/config.pbtxt +0 -22
  274. clarifai_utils/models/model_serving/examples/visual_embedding/vit-base/requirements.txt +0 -5
  275. clarifai_utils/models/model_serving/examples/visual_segmentation/README.md +0 -9
  276. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/1/__init__.py +0 -0
  277. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/1/inference.py +0 -55
  278. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/1/model.py +0 -60
  279. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/config.pbtxt +0 -24
  280. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/labels.txt +0 -18
  281. clarifai_utils/models/model_serving/examples/visual_segmentation/segformer-b2/requirements.txt +0 -5
  282. clarifai_utils/models/model_serving/model_config/__init__.py +0 -14
  283. clarifai_utils/models/model_serving/model_config/config.py +0 -302
  284. clarifai_utils/models/model_serving/model_config/inference_parameter.py +0 -124
  285. clarifai_utils/models/model_serving/model_config/model_types_config/multimodal-embedder.yaml +0 -24
  286. clarifai_utils/models/model_serving/model_config/model_types_config/text-classifier.yaml +0 -18
  287. clarifai_utils/models/model_serving/model_config/model_types_config/text-embedder.yaml +0 -18
  288. clarifai_utils/models/model_serving/model_config/model_types_config/text-to-image.yaml +0 -18
  289. clarifai_utils/models/model_serving/model_config/model_types_config/text-to-text.yaml +0 -18
  290. clarifai_utils/models/model_serving/model_config/model_types_config/visual-classifier.yaml +0 -18
  291. clarifai_utils/models/model_serving/model_config/model_types_config/visual-detector.yaml +0 -28
  292. clarifai_utils/models/model_serving/model_config/model_types_config/visual-embedder.yaml +0 -18
  293. clarifai_utils/models/model_serving/model_config/model_types_config/visual-segmenter.yaml +0 -18
  294. clarifai_utils/models/model_serving/model_config/serializer.py +0 -134
  295. clarifai_utils/models/model_serving/models/__init__.py +0 -12
  296. clarifai_utils/models/model_serving/models/default_test.py +0 -275
  297. clarifai_utils/models/model_serving/models/inference.py +0 -42
  298. clarifai_utils/models/model_serving/models/model_types.py +0 -265
  299. clarifai_utils/models/model_serving/models/output.py +0 -124
  300. clarifai_utils/models/model_serving/models/pb_model.py +0 -74
  301. clarifai_utils/models/model_serving/models/test.py +0 -64
  302. clarifai_utils/models/model_serving/pb_model_repository.py +0 -101
  303. clarifai_utils/modules/README.md +0 -5
  304. clarifai_utils/modules/__init__.py +0 -0
  305. clarifai_utils/modules/css.py +0 -60
  306. clarifai_utils/modules/pages.py +0 -42
  307. clarifai_utils/modules/style.css +0 -217
  308. clarifai_utils/runners/__init__.py +0 -0
  309. clarifai_utils/runners/example.py +0 -33
  310. clarifai_utils/schema/search.py +0 -69
  311. clarifai_utils/urls/helper.py +0 -103
  312. clarifai_utils/utils/__init__.py +0 -0
  313. clarifai_utils/utils/logging.py +0 -90
  314. clarifai_utils/utils/misc.py +0 -33
  315. clarifai_utils/utils/model_train.py +0 -157
  316. clarifai_utils/versions.py +0 -6
  317. clarifai_utils/workflows/__init__.py +0 -0
  318. clarifai_utils/workflows/export.py +0 -68
  319. clarifai_utils/workflows/utils.py +0 -59
  320. clarifai_utils/workflows/validate.py +0 -67
  321. {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/LICENSE +0 -0
  322. {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/WHEEL +0 -0
  323. {clarifai-9.10.2.dist-info → clarifai-9.10.3.dist-info}/entry_points.txt +0 -0
@@ -1,283 +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
- """Interface to Clarifai Models API."""
14
-
15
- from typing import Dict, List, Type
16
-
17
- from clarifai_grpc.grpc.api import resources_pb2, service_pb2
18
- from google.protobuf.json_format import MessageToDict
19
- from google.protobuf.struct_pb2 import Struct, Value
20
-
21
- from clarifai.auth.helper import ClarifaiAuthHelper
22
- from clarifai.client import create_stub
23
-
24
-
25
- def _make_default_value_proto(dtype, value):
26
- if dtype == 1:
27
- return Value(bool_value=value)
28
- elif dtype == 2 or dtype == 21:
29
- return Value(string_value=value)
30
- elif dtype == 3:
31
- return Value(number_value=value)
32
-
33
-
34
- class Models:
35
- """
36
- Interface to Clarifai models api
37
- """
38
-
39
- def __init__(self, auth: Type[ClarifaiAuthHelper]) -> None:
40
- self.auth = auth
41
- self.stub = create_stub(self.auth)
42
-
43
- def list_model_types(self) -> Dict:
44
- """
45
- List all API Model Types that support input and output.
46
-
47
- Returns:
48
- - A dict of;
49
- model_type, [{expected_input_name: value}, {expected_output_name: value}, model_descripton]
50
- key, value pairs respectively.i.e.
51
- {model_type: [{inp_field_name: value}, {output_field_name: value,...}, model_description]}
52
-
53
- - model_type: supported input shapes and data types dict. Structure;
54
- {model_type: [(supported_input_N_dims, dtypes_N),...]}
55
-
56
- - model_type: supported output shapes and data types dict. Structure;
57
- {model_type: [(supported_output_N_dims, dtypes_N),...]}
58
- """
59
- ## List model types from API
60
- model_types_response = self.stub.ListModelTypes(
61
- service_pb2.ListModelTypesRequest(), #(user_app_id=auth.user_app_id),
62
- metadata=self.auth.metadata)
63
- # model types dict structure:
64
- # {model_type: [{inp_field_name: value,}, {output_field_name: value,...}, desc]}
65
- model_types = {}
66
- in_dims_dtype = {} # {model_type: [(supported_input_N_dims, dtypes_N),...]}
67
- out_dims_dtype = {} # {model_type: [(supported_output_N_dims, dtypes_N),...]}
68
- types_dict = MessageToDict(
69
- model_types_response, preserving_proto_field_name=True)['model_types']
70
- for i in range(len(types_dict)):
71
- model_id = types_dict[i]['id']
72
- model_desc = types_dict[i]['description']
73
- if 'expected_output_layers' in types_dict[i].keys():
74
- # expected_input_layers exist for all expected_output_layers
75
- # hence one conditional check
76
- model_types[model_id] = []
77
- in_dims_dtype[model_id] = []
78
- out_dims_dtype[model_id] = []
79
- expected_input = types_dict[i]['expected_input_layers']
80
- expected_output = types_dict[i]['expected_output_layers']
81
- for inp in expected_input:
82
- if 'data_field_name' in inp.keys():
83
- model_types[model_id].append({inp['data_field_name']: None})
84
- if 'shapes' in inp.keys():
85
- for dim in inp['shapes']:
86
- if 'dims' in dim.keys():
87
- if 'max_dims' in dim.keys():
88
- in_dims_dtype[model_id].append((dim['dims'], dim['max_dims'], dim['data_type']))
89
- else:
90
- in_dims_dtype[model_id].append((dim['dims'], dim['data_type']))
91
- continue
92
- temp_out = {}
93
- for each in expected_output:
94
- if 'data_field_name' in each.keys():
95
- temp_out[each['data_field_name']] = None
96
- if 'shapes' in each.keys():
97
- for dim in each['shapes']:
98
-
99
- if 'dims' in dim.keys():
100
- out_dims_dtype[model_id].append((dim['dims'], dim['data_type']))
101
- else:
102
- continue
103
- model_types[model_id].append(temp_out)
104
- model_types[model_id].append(model_desc)
105
-
106
- return {
107
- "Model Types": model_types,
108
- "Input Metadata": in_dims_dtype,
109
- "Output Metadata": out_dims_dtype
110
- }
111
-
112
- def init_model(
113
- self,
114
- model_id: str,
115
- model_type: str,
116
- description: str = "",
117
- ):
118
- """Init a new model on Clarifai platform.
119
-
120
- Args:
121
- model_id (str): Clarifai model id
122
- model_type (str): Clarifai model type
123
- description (str, optional): a description of the model. Defaults to "".
124
-
125
- Returns:
126
- dict: Clarifai api response
127
- """
128
- user_data_object = self.auth.get_user_app_id_proto()
129
- post_models_response = self.stub.PostModels(
130
- service_pb2.PostModelsRequest(
131
- user_app_id=user_data_object,
132
- models=[resources_pb2.Model(id=model_id, notes=description,
133
- model_type_id=model_type)]),
134
- metadata=self.auth.metadata)
135
-
136
- return MessageToDict(post_models_response, preserving_proto_field_name=True)
137
-
138
- def post_model_version(self,
139
- model_id: str,
140
- model_zip_url: str,
141
- input: dict,
142
- outputs: dict,
143
- param_specs: List[dict] = None):
144
- """Post a new version of an existing model in the Clarifai platform.
145
-
146
- Args:
147
- model_id (str): Clarifai model id
148
- model_zip_url (str]): url of zip of model
149
- model_zip_url (str): url of zip of model
150
- input (dict): a dict where the key is clarifai input field and the value is triton model input,
151
- {clarifai_input_field: triton_input_filed}.
152
- outputs (dict): a dict where the keys are clarifai output fields and the values are triton model outputs,
153
- {clarifai_output_field1: triton_output_filed1, clarifai_output_field2: triton_output_filed2,...}.
154
- param_specs (List[dict]): list of dicts - keys are path, field_type, default_value, description. Default is None
155
- Returns:
156
- dict: clarifai api response
157
- """
158
- user_data_object = self.auth.get_user_app_id_proto()
159
-
160
- def _parse_fields_map(x):
161
- """parse input, outputs to Struct"""
162
- _fields_map = Struct()
163
- _fields_map.update(x)
164
- return _fields_map
165
-
166
- input_fields_map = _parse_fields_map(input)
167
- output_fields_map = _parse_fields_map(outputs)
168
- #resources_pb2.ModelTypeField(path="abc", default_value=1, description="test")
169
- if param_specs:
170
- iterative_proto_params = []
171
- for param in param_specs:
172
- dtype = param.get("field_type")
173
- proto_param = resources_pb2.ModelTypeField(
174
- path=param.get("path"),
175
- field_type=dtype,
176
- default_value=_make_default_value_proto(dtype=dtype, value=param.get("default_value")),
177
- description=param.get("description"),
178
- )
179
- iterative_proto_params.append(proto_param)
180
- param_specs = iterative_proto_params
181
-
182
- post_model_versions = self.stub.PostModelVersions(
183
- service_pb2.PostModelVersionsRequest(
184
- user_app_id=user_data_object,
185
- model_id=model_id,
186
- model_versions=[
187
- resources_pb2.ModelVersion(
188
- pretrained_model_config=resources_pb2.PretrainedModelConfig(
189
- model_zip_url=model_zip_url,
190
- input_fields_map=input_fields_map,
191
- output_fields_map=output_fields_map),
192
- output_info=resources_pb2.OutputInfo(params_specs=param_specs))
193
- ]),
194
- metadata=self.auth.metadata)
195
-
196
- return MessageToDict(post_model_versions, preserving_proto_field_name=True)
197
-
198
- def upload_model(self,
199
- model_id: str,
200
- model_zip_url: str,
201
- input: dict,
202
- outputs: dict,
203
- model_type: str,
204
- description: str = "",
205
- param_specs: List[dict] = None):
206
- """Doing 2 requests for initializing and creating version for a new trained model to the Clarifai platform.
207
-
208
- Args:
209
- model_id (str): Clarifai model id
210
- model_zip_url (str): url of zip of model
211
- input (dict): a dict where the key is clarifai input field and the value is triton model input,
212
- {clarifai_input_field: triton_input_filed}
213
- outputs (dict): a dict where the keys are clarifai output fields and the values are triton model outputs,
214
- {clarifai_output_field1: triton_output_filed1, clarifai_output_field2: triton_output_filed2,...}
215
- model_type (str): Clarifai model type.
216
- description (str, optional): a description of the model. Defaults to "".
217
- param_specs (List[dict]): list of dicts - keys are path, field_type, default_value, description. Default is None
218
-
219
- Returns:
220
- dict: Clarifai api response
221
- """
222
- init_resp = self.init_model(model_id, model_type, description)
223
- if init_resp["status"]["code"] != "SUCCESS":
224
- return init_resp
225
- version_resp = self.post_model_version(model_id, model_zip_url, input, outputs, param_specs)
226
-
227
- return version_resp
228
-
229
- def delete_model(self, model_id: str):
230
- """Delete model api by model id
231
-
232
- Args:
233
- model_id (str): Clarifai model id
234
-
235
- Returns:
236
- dict: clarifai api response
237
- """
238
- user_data_object = self.auth.get_user_app_id_proto()
239
- delete_model_response = self.stub.DeleteModel(
240
- service_pb2.DeleteModelRequest(
241
- user_app_id=user_data_object,
242
- model_id=model_id,
243
- ),
244
- metadata=self.auth.metadata)
245
-
246
- return MessageToDict(delete_model_response, preserving_proto_field_name=True)
247
-
248
- def delete_model_version(self, model_id: str, version_id: str):
249
- """Delete specific version of model
250
-
251
- Args:
252
- model_id (str): Clarifai model id
253
- version_id (str): version id of model that will be removed
254
-
255
- Returns:
256
- dict: Clarifai API response
257
- """
258
- user_data_object = self.auth.get_user_app_id_proto()
259
- delete_model_response = self.stub.DeleteModelVersion(
260
- service_pb2.DeleteModelVersionRequest(
261
- user_app_id=user_data_object, model_id=model_id, version_id=version_id),
262
- metadata=self.auth.metadata)
263
-
264
- return MessageToDict(delete_model_response, preserving_proto_field_name=True)
265
-
266
- def get_model(self, model_id: str):
267
- """Get model by id
268
-
269
- Args:
270
- model_id (str): Clarifai model id
271
-
272
- Returns:
273
- dict: Clarifai API response
274
- """
275
- user_data_object = self.auth.get_user_app_id_proto()
276
- response = self.stub.GetModel(
277
- service_pb2.GetModelRequest(
278
- user_app_id=user_data_object,
279
- model_id=model_id,
280
- ),
281
- metadata=self.auth.metadata)
282
-
283
- return MessageToDict(response, preserving_proto_field_name=True)
@@ -1,155 +0,0 @@
1
- ## Clarifai Model Serving: Deploy Your Machine Learning Models to Clarifai.
2
-
3
- Build and easily deploy machine learning models to Clarifai for inference using the [Nvidia Triton Inference Server](https://github.com/triton-inference-server/server).
4
-
5
- ## QuickStart Guide: Build a deployment ready model.
6
-
7
- A step by step guide to building your own triton inference model and deploying it into a Clarifai app.
8
-
9
- 1. Generate a triton model repository via commandline.
10
- ```console
11
- clarifai-model-upload-init --model_name <Your model name> \
12
- --model_type <select model type from available ones> \
13
- --repo_dir <directory in which to create your model repository>
14
- ```
15
- 2. 1. Edit the `requirements.txt` file with dependencies needed to run inference on your model and the `labels.txt` (if available in dir) with the labels your model is to predict.
16
- 2. Add your model loading and inference code inside `inference.py` script of the generated model repository under the `setup()` and `predict()` functions respectively. Refer to The [Inference Script section]() for a description of this file.
17
- 3. Inference parameters (optional): you can define some inference parameters that can be adjusted on model view of Clarifai platform when making prediction. Follow [this doc](./docs/inference_parameters.md) to build the json file.
18
- 3. Testing (Recommend) your implementation locally by running `<your_triton_folder>/1/test.py` with basic predefined tests.
19
- To avoid missing dependencies when deploying, recommend to use conda to create clean environment. Then install everything in `requirements.txt`. Follow instruction inside [test.py](./models/test.py) for implementing custom tests.
20
- * Create conda env and install requirements:
21
- ```bash
22
- # create env (note: only python version 3.8 is supported currently)
23
- conda create -n <your_env> python=3.8
24
- # activate it
25
- conda activate <your_env>
26
- # install dependencies
27
- pip install -r <your_triton_folder>/requirements.txt
28
- ```
29
- * Then run the test by using pytest:
30
-
31
- ```bash
32
- # Run the test
33
- pytest ./your_triton_folder/1/test.py
34
- # to see std output
35
- pytest --log-cli-level=INFO -s ./your_triton_folder/1/test.py
36
- ```
37
- 4. Generate a zip of your triton model for deployment via commandline.
38
- ```console
39
- clarifai-triton-zip --triton_model_repository <path to triton model repository to be compressed> \
40
- --zipfile_name <name of the triton model zip> (Recommended to use <model_name>_<model-type> convention for naming)
41
- ```
42
- 5. Upload the generated zip to a public file storage service to get a URL to the zip. This URL must be publicly accessible and downloadable as it's necessary for the last step: uploading the model to a Clarifai app.
43
- 6. Set your Clarifai auth credentials as environment variables.
44
- ```console
45
- export CLARIFAI_USER_ID=<your clarifai user_id>
46
- export CLARIFAI_APP_ID=<your clarifai app_id>
47
- export CLARIFAI_PAT=<your clarifai PAT>
48
- ```
49
- 7. Upload your model to Clarifai. Please ensure that your configuration field maps adhere to [this](https://github.com/Clarifai/clarifai-python-utils/blob/main/clarifai/models/model_serving/model_config/deploy.py)
50
- ```console
51
- clarifai-upload-model --url <URL to your model zip. Your zip file name is expected to have "zipfile_name" format (in clarifai-triton-zip), if not you need to specify your model_id and model_type> \
52
- --model_id <Your model ID on the platform> \
53
- --model_type <Clarifai model types> \
54
- --desc <A description of your model> \
55
- --update_version <Optional. Add new version of existing model> \
56
- --infer_param <Optional. Path to json file contains inference parameters>
57
- ```
58
-
59
- * Finally, navigate to your Clarifai app models and check that the deployed model appears. Click it on the model name to go the model versions table to track the status of the model deployment.
60
-
61
- ## Triton Model Repository
62
- ```diff
63
- <model_name>/
64
- ├── config.pbtx
65
- ├── requirements.txt
66
- ├── labels.txt (If applicable for given model-type)
67
- - ├── triton_conda.yaml
68
- └── 1/
69
- ├── __init__.py
70
- ├── inference.py
71
- ├── test.py
72
- └── model.py
73
- ```
74
-
75
- A generated triton model repository looks as illustrated in the directory tree above. Any additional files such as model checkpoints and folders needed at inference time must all be placed under the `1/` directory.
76
-
77
- - File Descriptions
78
-
79
- | Filename | Description & Use |
80
- | --- | --- |
81
- | `config.pbtxt` | Contains the triton model configuration used by the triton inference server to guide inference requests processing. |
82
- | `requirements.txt` | Contains dependencies needed by a user model to successfully make predictions.|
83
- | `labels.txt` | Contains labels listed one per line, a model is trained to predict. The order of labels should match the model predicted class indexes. |
84
- | `triton_conda.yaml` | Contains dependencies available in pre-configured execution environment. |
85
- | `1/inference.py` | The inference script where users write their inference code. |
86
- | `1/model.py` | The triton python backend model file run to serve inference requests. |
87
- | `1/test.py` | Contains some predefined tests in order to test inference implementation and dependencies locally. |
88
-
89
- ## Inference Script
90
-
91
- An `inference.py` script with template code is generated during the triton model repository generation.
92
- **This is the script where users write their inference code**.
93
- This script is composed of a single class that contains a default init method and the `get_predictions()` method whose names mustn't be changed.
94
-
95
- ```python
96
- """User model inference script."""
97
-
98
- import os
99
- from pathlib import Path
100
- from typing import Callable
101
-
102
- class InferenceModel:
103
- """User model inference class."""
104
-
105
- def __init__(self) -> None:
106
- """
107
- Load inference time artifacts that are called frequently .e.g. models, tokenizers, etc.
108
- in this method so they are loaded only once for faster inference.
109
- """
110
- self.base_path: Path = os.path.dirname(__file__)
111
- ## sample model loading code:
112
- #self.checkpoint_path: Path = os.path.join(self.base_path, "your checkpoint filename/path")
113
- #self.model: Callable = <load_your_model_here from checkpoint or folder>
114
-
115
- #Add relevant model type decorator to the method below (see docs/model_types for ref.)
116
- def get_predictions(self, input_data, **kwargs):
117
- """
118
- Main model inference method.
119
-
120
- Args:
121
- -----
122
- input_data: A single input data item to predict on.
123
- Input data can be an image or text, etc depending on the model type.
124
-
125
- Returns:
126
- --------
127
- One of the clarifai.models.model_serving.models.output types. Refer to the README/docs
128
- """
129
- # Delete/Comment out line below and add your inference code
130
- raise NotImplementedError()
131
- ```
132
-
133
- - `__init__()` used for one-time loading of inference time artifacts such as models, tokenizers, etc that are frequently called during inference to improve inference speed.
134
-
135
- - `get_predictions()` takes an input data item whose type depends on the task the model solves, & returns predictions for an input data item.
136
-
137
- `get_predictions()` should return any of the output types defined under [output](docs/output.md) and the predict function MUST be decorated with a task corresponding [model type decorator](docs/model_types.md). The model type decorators are responsible for passing input request batches for prediction and formatting the resultant predictions into triton inference responses.
138
-
139
- Additional methods can be added to this script's `Infer` class by the user as deemed necessary for their model inference provided they are invoked inside `get_predictions()` if used at inference time.
140
-
141
- ## Next steps
142
-
143
- - [Model types docs](docs/model_types.md)
144
- - [Model Output types docs](docs/output.md)
145
- - [Dependencies](docs/dependencies.md)
146
- - [Examples](examples/)
147
- - [Custom Configs](docs/custom_config.md/)
148
-
149
- ## Prerequisites
150
-
151
- * For deployment to Clarifai, you need a [Clarifai account](https://clarifai.com/signup).
152
-
153
- ## Testing
154
-
155
- * Please see https://github.com/Clarifai/clarifai-python/blob/master/clarifai/models/model_serving/models/test.py
@@ -1,12 +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.
@@ -1,12 +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.
@@ -1,123 +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
- """Commandline interface for model upload utils."""
14
- import argparse
15
-
16
- from clarifai.auth.helper import ClarifaiAuthHelper
17
- from clarifai.models.api import Models
18
- from clarifai.models.model_serving.model_config import MODEL_TYPES, get_model_config
19
- from clarifai.models.model_serving.model_config.inference_parameter import InferParamManager
20
-
21
-
22
- def deploy(model_url,
23
- model_id: str = None,
24
- model_type: str = None,
25
- desc: str = "",
26
- update_version: bool = False,
27
- inference_params_file: str = ""):
28
- # init Auth from env vars
29
- auth = ClarifaiAuthHelper.from_env()
30
- # init api
31
- model_api = Models(auth)
32
-
33
- # parsing model name/type.
34
- # if filename having this format: <model_id>_<model-type>
35
- # e.i yolov5s_coco_visual-dectector
36
- # else user has to input model_type and model_id
37
- zip_filename = model_url.split('/')[-1]
38
- zip_filename = zip_filename.split('.')[0]
39
-
40
- def _parse_name(name):
41
- *id_, type_ = name.split('_')
42
- return "_".join(id_), type_
43
-
44
- # parse model_id
45
- if not model_id and "_" in zip_filename:
46
- model_id = _parse_name(zip_filename)[0]
47
- assert model_id, "Can not parse model_id from url, please input it directly"
48
- # parse model_type
49
- if not model_type and "_" in zip_filename:
50
- model_type = _parse_name(zip_filename)[-1]
51
- assert model_type, "Can not parse model_type from url, please input it directly"
52
- # key map
53
- assert model_type in MODEL_TYPES, f"model_type should be one of {MODEL_TYPES}"
54
- clarifai_key_map = get_model_config(model_type=model_type).field_maps
55
- # inference parameters
56
- inference_parameters = InferParamManager(json_path=inference_params_file).get_list_params()
57
-
58
- # if updating new version of existing model
59
- if update_version:
60
- resp = model_api.post_model_version(
61
- model_id=model_id,
62
- model_zip_url=model_url,
63
- input=clarifai_key_map.input_fields_map,
64
- outputs=clarifai_key_map.output_fields_map,
65
- param_specs=inference_parameters)
66
- # creating new model
67
- else:
68
- # post model
69
- resp = model_api.upload_model(
70
- model_id=model_id,
71
- model_zip_url=model_url,
72
- model_type=model_type,
73
- input=clarifai_key_map.input_fields_map,
74
- outputs=clarifai_key_map.output_fields_map,
75
- description=desc,
76
- param_specs=inference_parameters)
77
- # response
78
- if resp["status"]["code"] != "SUCCESS":
79
- raise Exception("Post models failed, details: {}, {}".format(resp["status"]["description"],
80
- resp["status"]["details"]))
81
- else:
82
- print("Success!")
83
- print(f'Model version: {resp["model"]["model_version"]["id"]}')
84
-
85
-
86
- def main():
87
- parser = argparse.ArgumentParser(description=__doc__)
88
- # args
89
- parser.add_argument("--url", type=str, required=True, help="Direct download url of zip file")
90
- parser.add_argument("--model_id", type=str, required=False, default="", help="Custom model id.")
91
- parser.add_argument(
92
- "--model_type",
93
- type=str,
94
- required=False,
95
- choices=MODEL_TYPES,
96
- default="",
97
- help="Clarifai model type")
98
- parser.add_argument(
99
- "--desc", type=str, required=False, default="", help="Short desccription of model")
100
- parser.add_argument(
101
- "--update_version",
102
- action="store_true",
103
- required=False,
104
- help="Update exist model with new version")
105
-
106
- parser.add_argument(
107
- "--infer_param",
108
- required=False,
109
- default="",
110
- help="Path to json file contains inference parameters")
111
-
112
- args = parser.parse_args()
113
- deploy(
114
- model_url=args.url,
115
- model_id=args.model_id,
116
- desc=args.desc,
117
- model_type=args.model_type,
118
- update_version=args.update_version,
119
- inference_params_file=args.infer_param)
120
-
121
-
122
- if __name__ == "__main__":
123
- main()
@@ -1,61 +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 model zip commandline interface."""
14
-
15
- import argparse
16
- import zipfile
17
- from pathlib import Path
18
- from typing import Union
19
-
20
-
21
- def zip_dir(triton_repository_dir: Union[Path, str], zip_filename: Union[Path, str]):
22
- """
23
- Generate triton model repository zip file for upload.
24
- Args:
25
- -----
26
- triton_repository_dir: Directory of triton model respository to be zipped
27
- zip_filename: Triton model repository zip filename
28
-
29
- Returns:
30
- --------
31
- None
32
- """
33
- # Convert to Path object
34
- dir = Path(triton_repository_dir)
35
-
36
- with zipfile.ZipFile(zip_filename, "w", zipfile.ZIP_DEFLATED) as zip_file:
37
- for entry in dir.rglob("*"):
38
- zip_file.write(entry, entry.relative_to(dir))
39
-
40
-
41
- def main():
42
- """Triton model zip cli."""
43
- parser = argparse.ArgumentParser(__doc__)
44
- parser.add_argument(
45
- "--triton_model_repository",
46
- type=str,
47
- required=True,
48
- help="Path to the triton model repository to zip.")
49
- parser.add_argument(
50
- "--zipfile_name",
51
- type=str,
52
- required=True,
53
- help="Name of the zipfile to be created. \
54
- <model_name>_<model_type> is the recommended naming convention.e.g. yolov5_visual-detector.zip"
55
- )
56
- args = parser.parse_args()
57
- zip_dir(args.triton_model_repository, args.zipfile_name)
58
-
59
-
60
- if __name__ == "__main__":
61
- main()