clarifai 11.3.0rc2__py3-none-any.whl → 11.4.0__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 (300) hide show
  1. clarifai/__init__.py +1 -1
  2. clarifai/cli/__main__.py +1 -1
  3. clarifai/cli/base.py +144 -136
  4. clarifai/cli/compute_cluster.py +45 -31
  5. clarifai/cli/deployment.py +93 -76
  6. clarifai/cli/model.py +578 -180
  7. clarifai/cli/nodepool.py +100 -82
  8. clarifai/client/__init__.py +12 -2
  9. clarifai/client/app.py +973 -911
  10. clarifai/client/auth/helper.py +345 -342
  11. clarifai/client/auth/register.py +7 -7
  12. clarifai/client/auth/stub.py +107 -106
  13. clarifai/client/base.py +185 -178
  14. clarifai/client/compute_cluster.py +214 -180
  15. clarifai/client/dataset.py +793 -698
  16. clarifai/client/deployment.py +55 -50
  17. clarifai/client/input.py +1223 -1088
  18. clarifai/client/lister.py +47 -45
  19. clarifai/client/model.py +1939 -1717
  20. clarifai/client/model_client.py +525 -502
  21. clarifai/client/module.py +82 -73
  22. clarifai/client/nodepool.py +358 -213
  23. clarifai/client/runner.py +58 -0
  24. clarifai/client/search.py +342 -309
  25. clarifai/client/user.py +419 -414
  26. clarifai/client/workflow.py +294 -274
  27. clarifai/constants/dataset.py +11 -17
  28. clarifai/constants/model.py +8 -2
  29. clarifai/datasets/export/inputs_annotations.py +233 -217
  30. clarifai/datasets/upload/base.py +63 -51
  31. clarifai/datasets/upload/features.py +43 -38
  32. clarifai/datasets/upload/image.py +237 -207
  33. clarifai/datasets/upload/loaders/coco_captions.py +34 -32
  34. clarifai/datasets/upload/loaders/coco_detection.py +72 -65
  35. clarifai/datasets/upload/loaders/imagenet_classification.py +57 -53
  36. clarifai/datasets/upload/loaders/xview_detection.py +274 -132
  37. clarifai/datasets/upload/multimodal.py +55 -46
  38. clarifai/datasets/upload/text.py +55 -47
  39. clarifai/datasets/upload/utils.py +250 -234
  40. clarifai/errors.py +51 -50
  41. clarifai/models/api.py +260 -238
  42. clarifai/modules/css.py +50 -50
  43. clarifai/modules/pages.py +33 -33
  44. clarifai/rag/rag.py +312 -288
  45. clarifai/rag/utils.py +91 -84
  46. clarifai/runners/models/model_builder.py +906 -802
  47. clarifai/runners/models/model_class.py +370 -331
  48. clarifai/runners/models/model_run_locally.py +459 -419
  49. clarifai/runners/models/model_runner.py +170 -162
  50. clarifai/runners/models/model_servicer.py +78 -70
  51. clarifai/runners/server.py +111 -101
  52. clarifai/runners/utils/code_script.py +225 -187
  53. clarifai/runners/utils/const.py +4 -1
  54. clarifai/runners/utils/data_types/__init__.py +12 -0
  55. clarifai/runners/utils/data_types/data_types.py +598 -0
  56. clarifai/runners/utils/data_utils.py +387 -440
  57. clarifai/runners/utils/loader.py +247 -227
  58. clarifai/runners/utils/method_signatures.py +411 -386
  59. clarifai/runners/utils/openai_convertor.py +108 -109
  60. clarifai/runners/utils/serializers.py +175 -179
  61. clarifai/runners/utils/url_fetcher.py +35 -35
  62. clarifai/schema/search.py +56 -63
  63. clarifai/urls/helper.py +125 -102
  64. clarifai/utils/cli.py +129 -123
  65. clarifai/utils/config.py +127 -87
  66. clarifai/utils/constants.py +49 -0
  67. clarifai/utils/evaluation/helpers.py +503 -466
  68. clarifai/utils/evaluation/main.py +431 -393
  69. clarifai/utils/evaluation/testset_annotation_parser.py +154 -144
  70. clarifai/utils/logging.py +324 -306
  71. clarifai/utils/misc.py +60 -56
  72. clarifai/utils/model_train.py +165 -146
  73. clarifai/utils/protobuf.py +126 -103
  74. clarifai/versions.py +3 -1
  75. clarifai/workflows/export.py +48 -50
  76. clarifai/workflows/utils.py +39 -36
  77. clarifai/workflows/validate.py +55 -43
  78. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/METADATA +16 -6
  79. clarifai-11.4.0.dist-info/RECORD +109 -0
  80. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/WHEEL +1 -1
  81. clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
  82. clarifai/__pycache__/__init__.cpython-311.pyc +0 -0
  83. clarifai/__pycache__/__init__.cpython-39.pyc +0 -0
  84. clarifai/__pycache__/errors.cpython-310.pyc +0 -0
  85. clarifai/__pycache__/errors.cpython-311.pyc +0 -0
  86. clarifai/__pycache__/versions.cpython-310.pyc +0 -0
  87. clarifai/__pycache__/versions.cpython-311.pyc +0 -0
  88. clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  89. clarifai/cli/__pycache__/__init__.cpython-311.pyc +0 -0
  90. clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
  91. clarifai/cli/__pycache__/base.cpython-311.pyc +0 -0
  92. clarifai/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  93. clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  94. clarifai/cli/__pycache__/compute_cluster.cpython-311.pyc +0 -0
  95. clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
  96. clarifai/cli/__pycache__/deployment.cpython-311.pyc +0 -0
  97. clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
  98. clarifai/cli/__pycache__/model.cpython-311.pyc +0 -0
  99. clarifai/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  100. clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
  101. clarifai/cli/__pycache__/nodepool.cpython-311.pyc +0 -0
  102. clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
  103. clarifai/client/__pycache__/__init__.cpython-311.pyc +0 -0
  104. clarifai/client/__pycache__/__init__.cpython-39.pyc +0 -0
  105. clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
  106. clarifai/client/__pycache__/app.cpython-311.pyc +0 -0
  107. clarifai/client/__pycache__/app.cpython-39.pyc +0 -0
  108. clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
  109. clarifai/client/__pycache__/base.cpython-311.pyc +0 -0
  110. clarifai/client/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  111. clarifai/client/__pycache__/compute_cluster.cpython-311.pyc +0 -0
  112. clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
  113. clarifai/client/__pycache__/dataset.cpython-311.pyc +0 -0
  114. clarifai/client/__pycache__/deployment.cpython-310.pyc +0 -0
  115. clarifai/client/__pycache__/deployment.cpython-311.pyc +0 -0
  116. clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
  117. clarifai/client/__pycache__/input.cpython-311.pyc +0 -0
  118. clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
  119. clarifai/client/__pycache__/lister.cpython-311.pyc +0 -0
  120. clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
  121. clarifai/client/__pycache__/model.cpython-311.pyc +0 -0
  122. clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
  123. clarifai/client/__pycache__/module.cpython-311.pyc +0 -0
  124. clarifai/client/__pycache__/nodepool.cpython-310.pyc +0 -0
  125. clarifai/client/__pycache__/nodepool.cpython-311.pyc +0 -0
  126. clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
  127. clarifai/client/__pycache__/search.cpython-311.pyc +0 -0
  128. clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
  129. clarifai/client/__pycache__/user.cpython-311.pyc +0 -0
  130. clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
  131. clarifai/client/__pycache__/workflow.cpython-311.pyc +0 -0
  132. clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
  133. clarifai/client/auth/__pycache__/__init__.cpython-311.pyc +0 -0
  134. clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
  135. clarifai/client/auth/__pycache__/helper.cpython-311.pyc +0 -0
  136. clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
  137. clarifai/client/auth/__pycache__/register.cpython-311.pyc +0 -0
  138. clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
  139. clarifai/client/auth/__pycache__/stub.cpython-311.pyc +0 -0
  140. clarifai/client/cli/__init__.py +0 -0
  141. clarifai/client/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  142. clarifai/client/cli/__pycache__/base_cli.cpython-310.pyc +0 -0
  143. clarifai/client/cli/__pycache__/model_cli.cpython-310.pyc +0 -0
  144. clarifai/client/cli/base_cli.py +0 -88
  145. clarifai/client/cli/model_cli.py +0 -29
  146. clarifai/constants/__pycache__/base.cpython-310.pyc +0 -0
  147. clarifai/constants/__pycache__/base.cpython-311.pyc +0 -0
  148. clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
  149. clarifai/constants/__pycache__/dataset.cpython-311.pyc +0 -0
  150. clarifai/constants/__pycache__/input.cpython-310.pyc +0 -0
  151. clarifai/constants/__pycache__/input.cpython-311.pyc +0 -0
  152. clarifai/constants/__pycache__/model.cpython-310.pyc +0 -0
  153. clarifai/constants/__pycache__/model.cpython-311.pyc +0 -0
  154. clarifai/constants/__pycache__/rag.cpython-310.pyc +0 -0
  155. clarifai/constants/__pycache__/rag.cpython-311.pyc +0 -0
  156. clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
  157. clarifai/constants/__pycache__/search.cpython-311.pyc +0 -0
  158. clarifai/constants/__pycache__/workflow.cpython-310.pyc +0 -0
  159. clarifai/constants/__pycache__/workflow.cpython-311.pyc +0 -0
  160. clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
  161. clarifai/datasets/__pycache__/__init__.cpython-311.pyc +0 -0
  162. clarifai/datasets/__pycache__/__init__.cpython-39.pyc +0 -0
  163. clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
  164. clarifai/datasets/export/__pycache__/__init__.cpython-311.pyc +0 -0
  165. clarifai/datasets/export/__pycache__/__init__.cpython-39.pyc +0 -0
  166. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
  167. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-311.pyc +0 -0
  168. clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
  169. clarifai/datasets/upload/__pycache__/__init__.cpython-311.pyc +0 -0
  170. clarifai/datasets/upload/__pycache__/__init__.cpython-39.pyc +0 -0
  171. clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
  172. clarifai/datasets/upload/__pycache__/base.cpython-311.pyc +0 -0
  173. clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
  174. clarifai/datasets/upload/__pycache__/features.cpython-311.pyc +0 -0
  175. clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
  176. clarifai/datasets/upload/__pycache__/image.cpython-311.pyc +0 -0
  177. clarifai/datasets/upload/__pycache__/multimodal.cpython-310.pyc +0 -0
  178. clarifai/datasets/upload/__pycache__/multimodal.cpython-311.pyc +0 -0
  179. clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
  180. clarifai/datasets/upload/__pycache__/text.cpython-311.pyc +0 -0
  181. clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
  182. clarifai/datasets/upload/__pycache__/utils.cpython-311.pyc +0 -0
  183. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-311.pyc +0 -0
  184. clarifai/datasets/upload/loaders/__pycache__/__init__.cpython-39.pyc +0 -0
  185. clarifai/datasets/upload/loaders/__pycache__/coco_detection.cpython-311.pyc +0 -0
  186. clarifai/datasets/upload/loaders/__pycache__/imagenet_classification.cpython-311.pyc +0 -0
  187. clarifai/models/__pycache__/__init__.cpython-39.pyc +0 -0
  188. clarifai/modules/__pycache__/__init__.cpython-39.pyc +0 -0
  189. clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
  190. clarifai/rag/__pycache__/__init__.cpython-311.pyc +0 -0
  191. clarifai/rag/__pycache__/__init__.cpython-39.pyc +0 -0
  192. clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
  193. clarifai/rag/__pycache__/rag.cpython-311.pyc +0 -0
  194. clarifai/rag/__pycache__/rag.cpython-39.pyc +0 -0
  195. clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
  196. clarifai/rag/__pycache__/utils.cpython-311.pyc +0 -0
  197. clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
  198. clarifai/runners/__pycache__/__init__.cpython-311.pyc +0 -0
  199. clarifai/runners/__pycache__/__init__.cpython-39.pyc +0 -0
  200. clarifai/runners/dockerfile_template/Dockerfile.cpu.template +0 -31
  201. clarifai/runners/dockerfile_template/Dockerfile.cuda.template +0 -42
  202. clarifai/runners/dockerfile_template/Dockerfile.nim +0 -71
  203. clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
  204. clarifai/runners/models/__pycache__/__init__.cpython-311.pyc +0 -0
  205. clarifai/runners/models/__pycache__/__init__.cpython-39.pyc +0 -0
  206. clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
  207. clarifai/runners/models/__pycache__/base_typed_model.cpython-311.pyc +0 -0
  208. clarifai/runners/models/__pycache__/base_typed_model.cpython-39.pyc +0 -0
  209. clarifai/runners/models/__pycache__/model_builder.cpython-311.pyc +0 -0
  210. clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
  211. clarifai/runners/models/__pycache__/model_class.cpython-311.pyc +0 -0
  212. clarifai/runners/models/__pycache__/model_run_locally.cpython-310-pytest-7.1.2.pyc +0 -0
  213. clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
  214. clarifai/runners/models/__pycache__/model_run_locally.cpython-311.pyc +0 -0
  215. clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
  216. clarifai/runners/models/__pycache__/model_runner.cpython-311.pyc +0 -0
  217. clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
  218. clarifai/runners/models/base_typed_model.py +0 -238
  219. clarifai/runners/models/model_class_refract.py +0 -80
  220. clarifai/runners/models/model_upload.py +0 -607
  221. clarifai/runners/models/temp.py +0 -25
  222. clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  223. clarifai/runners/utils/__pycache__/__init__.cpython-311.pyc +0 -0
  224. clarifai/runners/utils/__pycache__/__init__.cpython-38.pyc +0 -0
  225. clarifai/runners/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  226. clarifai/runners/utils/__pycache__/buffered_stream.cpython-310.pyc +0 -0
  227. clarifai/runners/utils/__pycache__/buffered_stream.cpython-38.pyc +0 -0
  228. clarifai/runners/utils/__pycache__/buffered_stream.cpython-39.pyc +0 -0
  229. clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
  230. clarifai/runners/utils/__pycache__/const.cpython-311.pyc +0 -0
  231. clarifai/runners/utils/__pycache__/constants.cpython-310.pyc +0 -0
  232. clarifai/runners/utils/__pycache__/constants.cpython-38.pyc +0 -0
  233. clarifai/runners/utils/__pycache__/constants.cpython-39.pyc +0 -0
  234. clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
  235. clarifai/runners/utils/__pycache__/data_handler.cpython-311.pyc +0 -0
  236. clarifai/runners/utils/__pycache__/data_handler.cpython-38.pyc +0 -0
  237. clarifai/runners/utils/__pycache__/data_handler.cpython-39.pyc +0 -0
  238. clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
  239. clarifai/runners/utils/__pycache__/data_utils.cpython-311.pyc +0 -0
  240. clarifai/runners/utils/__pycache__/data_utils.cpython-38.pyc +0 -0
  241. clarifai/runners/utils/__pycache__/data_utils.cpython-39.pyc +0 -0
  242. clarifai/runners/utils/__pycache__/grpc_server.cpython-310.pyc +0 -0
  243. clarifai/runners/utils/__pycache__/grpc_server.cpython-38.pyc +0 -0
  244. clarifai/runners/utils/__pycache__/grpc_server.cpython-39.pyc +0 -0
  245. clarifai/runners/utils/__pycache__/health.cpython-310.pyc +0 -0
  246. clarifai/runners/utils/__pycache__/health.cpython-38.pyc +0 -0
  247. clarifai/runners/utils/__pycache__/health.cpython-39.pyc +0 -0
  248. clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
  249. clarifai/runners/utils/__pycache__/loader.cpython-311.pyc +0 -0
  250. clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
  251. clarifai/runners/utils/__pycache__/logging.cpython-38.pyc +0 -0
  252. clarifai/runners/utils/__pycache__/logging.cpython-39.pyc +0 -0
  253. clarifai/runners/utils/__pycache__/stream_source.cpython-310.pyc +0 -0
  254. clarifai/runners/utils/__pycache__/stream_source.cpython-39.pyc +0 -0
  255. clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
  256. clarifai/runners/utils/__pycache__/url_fetcher.cpython-311.pyc +0 -0
  257. clarifai/runners/utils/__pycache__/url_fetcher.cpython-38.pyc +0 -0
  258. clarifai/runners/utils/__pycache__/url_fetcher.cpython-39.pyc +0 -0
  259. clarifai/runners/utils/data_handler.py +0 -231
  260. clarifai/runners/utils/data_handler_refract.py +0 -213
  261. clarifai/runners/utils/data_types.py +0 -469
  262. clarifai/runners/utils/logger.py +0 -0
  263. clarifai/runners/utils/openai_format.py +0 -87
  264. clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
  265. clarifai/schema/__pycache__/search.cpython-311.pyc +0 -0
  266. clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
  267. clarifai/urls/__pycache__/helper.cpython-311.pyc +0 -0
  268. clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  269. clarifai/utils/__pycache__/__init__.cpython-311.pyc +0 -0
  270. clarifai/utils/__pycache__/__init__.cpython-39.pyc +0 -0
  271. clarifai/utils/__pycache__/cli.cpython-310.pyc +0 -0
  272. clarifai/utils/__pycache__/cli.cpython-311.pyc +0 -0
  273. clarifai/utils/__pycache__/config.cpython-311.pyc +0 -0
  274. clarifai/utils/__pycache__/constants.cpython-310.pyc +0 -0
  275. clarifai/utils/__pycache__/constants.cpython-311.pyc +0 -0
  276. clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
  277. clarifai/utils/__pycache__/logging.cpython-311.pyc +0 -0
  278. clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
  279. clarifai/utils/__pycache__/misc.cpython-311.pyc +0 -0
  280. clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
  281. clarifai/utils/__pycache__/model_train.cpython-311.pyc +0 -0
  282. clarifai/utils/__pycache__/protobuf.cpython-311.pyc +0 -0
  283. clarifai/utils/evaluation/__pycache__/__init__.cpython-311.pyc +0 -0
  284. clarifai/utils/evaluation/__pycache__/__init__.cpython-39.pyc +0 -0
  285. clarifai/utils/evaluation/__pycache__/helpers.cpython-311.pyc +0 -0
  286. clarifai/utils/evaluation/__pycache__/main.cpython-311.pyc +0 -0
  287. clarifai/utils/evaluation/__pycache__/main.cpython-39.pyc +0 -0
  288. clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
  289. clarifai/workflows/__pycache__/__init__.cpython-311.pyc +0 -0
  290. clarifai/workflows/__pycache__/__init__.cpython-39.pyc +0 -0
  291. clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
  292. clarifai/workflows/__pycache__/export.cpython-311.pyc +0 -0
  293. clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
  294. clarifai/workflows/__pycache__/utils.cpython-311.pyc +0 -0
  295. clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
  296. clarifai/workflows/__pycache__/validate.cpython-311.pyc +0 -0
  297. clarifai-11.3.0rc2.dist-info/RECORD +0 -322
  298. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/entry_points.txt +0 -0
  299. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info/licenses}/LICENSE +0 -0
  300. {clarifai-11.3.0rc2.dist-info → clarifai-11.4.0.dist-info}/top_level.txt +0 -0
@@ -15,138 +15,280 @@ from ..features import VisualDetectionFeatures
15
15
 
16
16
 
17
17
  class xviewDetectionDataLoader(ClarifaiDataLoader):
18
- """xview Image Detection Dataset"""
19
-
20
- xview_concepts = [
21
- 'Fixed-wing Aircraft', 'Small Aircraft', 'Cargo Plane', 'Helicopter', 'Passenger Vehicle',
22
- 'Small Car', 'Bus', 'Pickup Truck', 'Utility Truck', 'Truck', 'Cargo Truck', 'Truck w-Box',
23
- 'Truck Tractor', 'Trailer', 'Truck w-Flatbed', 'Truck w-Liquid', 'Crane Truck',
24
- 'Railway Vehicle', 'Passenger Car', 'Cargo Car', 'Flat Car', 'Tank car', 'Locomotive',
25
- 'Maritime Vessel', 'Motorboat', 'Sailboat', 'Tugboat', 'Barge', 'Fishing Vessel', 'Ferry',
26
- 'Yacht', 'Container Ship', 'Oil Tanker', 'Engineering Vehicle', 'Tower crane',
27
- 'Container Crane', 'Reach Stacker', 'Straddle Carrier', 'Mobile Crane', 'Dump Truck',
28
- 'Haul Truck', 'Scraper-Tractor', 'Front loader-Bulldozer', 'Excavator', 'Cement Mixer',
29
- 'Ground Grader', 'Hut-Tent', 'Shed', 'Building', 'Aircraft Hangar', 'Damaged Building',
30
- 'Facility', 'Construction Site', 'Vehicle Lot', 'Helipad', 'Storage Tank',
31
- 'Shipping container lot', 'Shipping Container', 'Pylon', 'Tower'
32
- ]
33
-
34
- def __init__(self, data_dir) -> None:
35
- """Initialize and Compress xview dataset.
36
- Args:
37
- data_dir: the local dataset directory.
38
- """
39
-
40
- self.data_dir = data_dir
41
- self.img_dir = os.path.join(self.data_dir, "train_images")
42
- self.img_comp_dir = os.path.join(self.data_dir, "train_images_comp")
43
- self.label_file = os.path.join(self.data_dir, "xview_train.geojson")
44
-
45
- self.preprocess()
46
- self.all_data = self.xview_data_parser()
47
-
48
- self.load_data()
49
-
50
- @property
51
- def task(self):
52
- return "visual_detection"
53
-
54
- def compress_tiff(self, img_path: str) -> None:
55
- """Compress tiff image"""
56
- img_comp_path = os.path.join(self.img_comp_dir, os.path.basename(img_path))
57
- img_arr = Image.open(img_path)
58
- img_arr.save(img_comp_path, 'TIFF', compression='tiff_deflate')
59
-
60
- def preprocess(self):
61
- """Compress the tiff images to comply with clarifai grpc image encoding limit(<20MB) Uses ADOBE_DEFLATE compression algorithm"""
62
- all_img_ids = glob.glob(os.path.join(self.img_dir, "*.tif"))
63
-
64
- if not os.path.exists(self.img_comp_dir):
65
- os.mkdir(self.img_comp_dir)
66
-
67
- num_workers = cpu_count()
68
- futures = []
69
-
70
- with ThreadPoolExecutor(max_workers=num_workers) as executor:
71
- with tqdm(total=len(all_img_ids), desc="compressing ...") as progress:
72
-
73
- for img_path in all_img_ids:
74
- future = executor.submit(self.compress_tiff, img_path)
75
- future.add_done_callback(lambda _: progress.update())
76
- futures.append(future)
77
-
78
- results = []
79
- for future in futures:
80
- result = future.result()
81
- results.append(result)
82
-
83
- def xview_classes2indices(self, classes: List) -> List:
84
- """remap xview classes 11-94 to 0-59"""
85
- indices = [
86
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, -1, 3, -1, 4, 5, 6, 7, 8, -1, 9, 10,
87
- 11, 12, 13, 14, 15, -1, -1, 16, 17, 18, 19, 20, 21, 22, -1, 23, 24, 25, -1, 26, 27, -1, 28,
88
- -1, 29, 30, 31, 32, 33, 34, 35, 36, 37, -1, 38, 39, 40, 41, 42, 43, 44, 45, -1, -1, -1, -1,
89
- 46, 47, 48, 49, -1, 50, 51, -1, 52, -1, -1, -1, 53, 54, -1, 55, -1, -1, 56, -1, 57, -1, 58,
90
- 59
18
+ """xview Image Detection Dataset"""
19
+
20
+ xview_concepts = [
21
+ 'Fixed-wing Aircraft',
22
+ 'Small Aircraft',
23
+ 'Cargo Plane',
24
+ 'Helicopter',
25
+ 'Passenger Vehicle',
26
+ 'Small Car',
27
+ 'Bus',
28
+ 'Pickup Truck',
29
+ 'Utility Truck',
30
+ 'Truck',
31
+ 'Cargo Truck',
32
+ 'Truck w-Box',
33
+ 'Truck Tractor',
34
+ 'Trailer',
35
+ 'Truck w-Flatbed',
36
+ 'Truck w-Liquid',
37
+ 'Crane Truck',
38
+ 'Railway Vehicle',
39
+ 'Passenger Car',
40
+ 'Cargo Car',
41
+ 'Flat Car',
42
+ 'Tank car',
43
+ 'Locomotive',
44
+ 'Maritime Vessel',
45
+ 'Motorboat',
46
+ 'Sailboat',
47
+ 'Tugboat',
48
+ 'Barge',
49
+ 'Fishing Vessel',
50
+ 'Ferry',
51
+ 'Yacht',
52
+ 'Container Ship',
53
+ 'Oil Tanker',
54
+ 'Engineering Vehicle',
55
+ 'Tower crane',
56
+ 'Container Crane',
57
+ 'Reach Stacker',
58
+ 'Straddle Carrier',
59
+ 'Mobile Crane',
60
+ 'Dump Truck',
61
+ 'Haul Truck',
62
+ 'Scraper-Tractor',
63
+ 'Front loader-Bulldozer',
64
+ 'Excavator',
65
+ 'Cement Mixer',
66
+ 'Ground Grader',
67
+ 'Hut-Tent',
68
+ 'Shed',
69
+ 'Building',
70
+ 'Aircraft Hangar',
71
+ 'Damaged Building',
72
+ 'Facility',
73
+ 'Construction Site',
74
+ 'Vehicle Lot',
75
+ 'Helipad',
76
+ 'Storage Tank',
77
+ 'Shipping container lot',
78
+ 'Shipping Container',
79
+ 'Pylon',
80
+ 'Tower',
91
81
  ]
92
- return [indices[int(c)] for c in classes]
93
-
94
- def xview_indices2concepts(self, indices: List) -> List:
95
- """remap classes to concept names"""
96
- return [self.xview_concepts[i] for i in indices]
97
-
98
- def xview_data_parser(self) -> DefaultDict[str, Dict[List, List]]:
99
- """Parse geojson data into nested dict of imageid w.r.t bounding boxes, concepts"""
100
- all_data = defaultdict(lambda: dict(bboxes=[], concepts=[]))
101
-
102
- with open(self.label_file) as f:
103
- geojson_data = json.loads(f.read())
104
-
105
- for feature in tqdm(
106
- geojson_data['features'], total=len(geojson_data['features']),
107
- desc="Parsing geojson data"):
108
- image_id = feature['properties']['image_id'].split(".")[0]
109
- xview_classid = feature['properties']['type_id']
110
- bbox = list(map(int, feature['properties']['bounds_imcoords'].split(",")))
111
- concept = self.xview_indices2concepts(self.xview_classes2indices([xview_classid]))
112
-
113
- all_data[image_id]['bboxes'].append(bbox)
114
- all_data[image_id]['concepts'].append(concept[0])
115
-
116
- return all_data
117
-
118
- def load_data(self):
119
- """Load image paths"""
120
- self.image_paths = []
121
- all_img_ids = glob.glob(os.path.join(self.img_comp_dir, "*.tif"))
122
- self.image_paths = all_img_ids
123
-
124
- def __len__(self):
125
- return len(self.image_paths)
126
-
127
- def __getitem__(self, index: int):
128
- """Get dataset for a given index.
129
- Returns:
130
- VisualDetectionFeature type.
131
- """
132
- _id = os.path.splitext(os.path.basename(self.image_paths[index]))[0]
133
- image_path = self.image_paths[index]
134
-
135
- image = Image.open(image_path)
136
- image_width, image_height = image.size
137
- annots = []
138
- class_names = []
139
- for bbox, concept in zip(self.all_data[_id]['bboxes'], self.all_data[_id]['concepts']):
140
- x_min = max(min(bbox[0] / image_width, 1.0), 0.0) #left_col
141
- y_min = max(min(bbox[1] / image_height, 1.0), 0.0) #top_row
142
- x_max = max(min(bbox[2] / image_width, 1.0), 0.0) #right_col
143
- y_max = max(min(bbox[3] / image_height, 1.0), 0.0) #bottom_row
144
- if (x_min >= x_max) or (y_min >= y_max):
145
- continue
146
- annots.append([x for x in [x_min, y_min, x_max, y_max]])
147
- class_names.append(concept)
148
-
149
- assert len(class_names) == len(annots), f"Num classes must match num bbox annotations\
82
+
83
+ def __init__(self, data_dir) -> None:
84
+ """Initialize and Compress xview dataset.
85
+ Args:
86
+ data_dir: the local dataset directory.
87
+ """
88
+
89
+ self.data_dir = data_dir
90
+ self.img_dir = os.path.join(self.data_dir, "train_images")
91
+ self.img_comp_dir = os.path.join(self.data_dir, "train_images_comp")
92
+ self.label_file = os.path.join(self.data_dir, "xview_train.geojson")
93
+
94
+ self.preprocess()
95
+ self.all_data = self.xview_data_parser()
96
+
97
+ self.load_data()
98
+
99
+ @property
100
+ def task(self):
101
+ return "visual_detection"
102
+
103
+ def compress_tiff(self, img_path: str) -> None:
104
+ """Compress tiff image"""
105
+ img_comp_path = os.path.join(self.img_comp_dir, os.path.basename(img_path))
106
+ img_arr = Image.open(img_path)
107
+ img_arr.save(img_comp_path, 'TIFF', compression='tiff_deflate')
108
+
109
+ def preprocess(self):
110
+ """Compress the tiff images to comply with clarifai grpc image encoding limit(<20MB) Uses ADOBE_DEFLATE compression algorithm"""
111
+ all_img_ids = glob.glob(os.path.join(self.img_dir, "*.tif"))
112
+
113
+ if not os.path.exists(self.img_comp_dir):
114
+ os.mkdir(self.img_comp_dir)
115
+
116
+ num_workers = cpu_count()
117
+ futures = []
118
+
119
+ with ThreadPoolExecutor(max_workers=num_workers) as executor:
120
+ with tqdm(total=len(all_img_ids), desc="compressing ...") as progress:
121
+ for img_path in all_img_ids:
122
+ future = executor.submit(self.compress_tiff, img_path)
123
+ future.add_done_callback(lambda _: progress.update())
124
+ futures.append(future)
125
+
126
+ results = []
127
+ for future in futures:
128
+ result = future.result()
129
+ results.append(result)
130
+
131
+ def xview_classes2indices(self, classes: List) -> List:
132
+ """remap xview classes 11-94 to 0-59"""
133
+ indices = [
134
+ -1,
135
+ -1,
136
+ -1,
137
+ -1,
138
+ -1,
139
+ -1,
140
+ -1,
141
+ -1,
142
+ -1,
143
+ -1,
144
+ -1,
145
+ 0,
146
+ 1,
147
+ 2,
148
+ -1,
149
+ 3,
150
+ -1,
151
+ 4,
152
+ 5,
153
+ 6,
154
+ 7,
155
+ 8,
156
+ -1,
157
+ 9,
158
+ 10,
159
+ 11,
160
+ 12,
161
+ 13,
162
+ 14,
163
+ 15,
164
+ -1,
165
+ -1,
166
+ 16,
167
+ 17,
168
+ 18,
169
+ 19,
170
+ 20,
171
+ 21,
172
+ 22,
173
+ -1,
174
+ 23,
175
+ 24,
176
+ 25,
177
+ -1,
178
+ 26,
179
+ 27,
180
+ -1,
181
+ 28,
182
+ -1,
183
+ 29,
184
+ 30,
185
+ 31,
186
+ 32,
187
+ 33,
188
+ 34,
189
+ 35,
190
+ 36,
191
+ 37,
192
+ -1,
193
+ 38,
194
+ 39,
195
+ 40,
196
+ 41,
197
+ 42,
198
+ 43,
199
+ 44,
200
+ 45,
201
+ -1,
202
+ -1,
203
+ -1,
204
+ -1,
205
+ 46,
206
+ 47,
207
+ 48,
208
+ 49,
209
+ -1,
210
+ 50,
211
+ 51,
212
+ -1,
213
+ 52,
214
+ -1,
215
+ -1,
216
+ -1,
217
+ 53,
218
+ 54,
219
+ -1,
220
+ 55,
221
+ -1,
222
+ -1,
223
+ 56,
224
+ -1,
225
+ 57,
226
+ -1,
227
+ 58,
228
+ 59,
229
+ ]
230
+ return [indices[int(c)] for c in classes]
231
+
232
+ def xview_indices2concepts(self, indices: List) -> List:
233
+ """remap classes to concept names"""
234
+ return [self.xview_concepts[i] for i in indices]
235
+
236
+ def xview_data_parser(self) -> DefaultDict[str, Dict[List, List]]:
237
+ """Parse geojson data into nested dict of imageid w.r.t bounding boxes, concepts"""
238
+ all_data = defaultdict(lambda: dict(bboxes=[], concepts=[]))
239
+
240
+ with open(self.label_file) as f:
241
+ geojson_data = json.loads(f.read())
242
+
243
+ for feature in tqdm(
244
+ geojson_data['features'],
245
+ total=len(geojson_data['features']),
246
+ desc="Parsing geojson data",
247
+ ):
248
+ image_id = feature['properties']['image_id'].split(".")[0]
249
+ xview_classid = feature['properties']['type_id']
250
+ bbox = list(map(int, feature['properties']['bounds_imcoords'].split(",")))
251
+ concept = self.xview_indices2concepts(self.xview_classes2indices([xview_classid]))
252
+
253
+ all_data[image_id]['bboxes'].append(bbox)
254
+ all_data[image_id]['concepts'].append(concept[0])
255
+
256
+ return all_data
257
+
258
+ def load_data(self):
259
+ """Load image paths"""
260
+ self.image_paths = []
261
+ all_img_ids = glob.glob(os.path.join(self.img_comp_dir, "*.tif"))
262
+ self.image_paths = all_img_ids
263
+
264
+ def __len__(self):
265
+ return len(self.image_paths)
266
+
267
+ def __getitem__(self, index: int):
268
+ """Get dataset for a given index.
269
+ Returns:
270
+ VisualDetectionFeature type.
271
+ """
272
+ _id = os.path.splitext(os.path.basename(self.image_paths[index]))[0]
273
+ image_path = self.image_paths[index]
274
+
275
+ image = Image.open(image_path)
276
+ image_width, image_height = image.size
277
+ annots = []
278
+ class_names = []
279
+ for bbox, concept in zip(self.all_data[_id]['bboxes'], self.all_data[_id]['concepts']):
280
+ x_min = max(min(bbox[0] / image_width, 1.0), 0.0) # left_col
281
+ y_min = max(min(bbox[1] / image_height, 1.0), 0.0) # top_row
282
+ x_max = max(min(bbox[2] / image_width, 1.0), 0.0) # right_col
283
+ y_max = max(min(bbox[3] / image_height, 1.0), 0.0) # bottom_row
284
+ if (x_min >= x_max) or (y_min >= y_max):
285
+ continue
286
+ annots.append([x for x in [x_min, y_min, x_max, y_max]])
287
+ class_names.append(concept)
288
+
289
+ assert len(class_names) == len(annots), (
290
+ f"Num classes must match num bbox annotations\
150
291
  for a single image. Found {len(class_names)} classes and {len(annots)} bboxes."
292
+ )
151
293
 
152
- return VisualDetectionFeatures(image_path, class_names, annots, id=_id)
294
+ return VisualDetectionFeatures(image_path, class_names, annots, id=_id)
@@ -9,61 +9,70 @@ from clarifai.datasets.upload.base import ClarifaiDataLoader, ClarifaiDataset
9
9
 
10
10
 
11
11
  class MultiModalDataset(ClarifaiDataset):
12
+ def __init__(
13
+ self, data_generator: Type[ClarifaiDataLoader], dataset_id: str, max_workers: int = 4
14
+ ) -> None:
15
+ super().__init__(data_generator, dataset_id, max_workers)
12
16
 
13
- def __init__(self,
14
- data_generator: Type[ClarifaiDataLoader],
15
- dataset_id: str,
16
- max_workers: int = 4) -> None:
17
- super().__init__(data_generator, dataset_id, max_workers)
18
-
19
- def _extract_protos(
20
- self,
21
- batch_input_ids: List[str],
22
- ) -> Tuple[List[resources_pb2.Input]]:
23
- """ Creats Multimodal (image and text) input protos for batch of input ids.
17
+ def _extract_protos(
18
+ self,
19
+ batch_input_ids: List[str],
20
+ ) -> Tuple[List[resources_pb2.Input]]:
21
+ """Creats Multimodal (image and text) input protos for batch of input ids.
24
22
  Args:
25
23
  batch_input_ids: List of input IDs to retrieve the protos for.
26
24
  Returns:
27
25
  input_protos: List of input protos.
28
26
 
29
27
  """
30
- input_protos, annotation_protos = [], []
28
+ input_protos, annotation_protos = [], []
31
29
 
32
- def process_data_item(id):
33
- data_item = self.data_generator[id]
34
- metadata = Struct()
35
- image_bytes = data_item.image_bytes
36
- text = data_item.text
37
- labels = data_item.labels if ((data_item.labels is None) or
38
- isinstance(data_item.labels, list)) else [data_item.labels]
39
- input_id = f"{self.dataset_id}-{id}" if data_item.id is None else f"{self.dataset_id}-{str(data_item.id)}"
40
- if data_item.metadata is not None:
41
- metadata.update(data_item.metadata)
42
- else:
43
- metadata = None
30
+ def process_data_item(id):
31
+ data_item = self.data_generator[id]
32
+ metadata = Struct()
33
+ image_bytes = data_item.image_bytes
34
+ text = data_item.text
35
+ labels = (
36
+ data_item.labels
37
+ if ((data_item.labels is None) or isinstance(data_item.labels, list))
38
+ else [data_item.labels]
39
+ )
40
+ input_id = (
41
+ f"{self.dataset_id}-{id}"
42
+ if data_item.id is None
43
+ else f"{self.dataset_id}-{str(data_item.id)}"
44
+ )
45
+ if data_item.metadata is not None:
46
+ metadata.update(data_item.metadata)
47
+ else:
48
+ metadata = None
44
49
 
45
- self.all_input_ids[id] = input_id
46
- if data_item.image_bytes is not None:
47
- input_protos.append(
48
- Inputs.get_input_from_bytes(
49
- input_id=input_id,
50
- image_bytes=image_bytes,
51
- dataset_id=self.dataset_id,
52
- labels=labels,
53
- metadata=metadata))
54
- else:
55
- input_protos.append(
56
- Inputs.get_text_input(
57
- input_id=input_id,
58
- raw_text=text,
59
- dataset_id=self.dataset_id,
60
- labels=labels,
61
- metadata=metadata))
50
+ self.all_input_ids[id] = input_id
51
+ if data_item.image_bytes is not None:
52
+ input_protos.append(
53
+ Inputs.get_input_from_bytes(
54
+ input_id=input_id,
55
+ image_bytes=image_bytes,
56
+ dataset_id=self.dataset_id,
57
+ labels=labels,
58
+ metadata=metadata,
59
+ )
60
+ )
61
+ else:
62
+ input_protos.append(
63
+ Inputs.get_text_input(
64
+ input_id=input_id,
65
+ raw_text=text,
66
+ dataset_id=self.dataset_id,
67
+ labels=labels,
68
+ metadata=metadata,
69
+ )
70
+ )
62
71
 
63
- with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
64
- futures = [executor.submit(process_data_item, id) for id in batch_input_ids]
72
+ with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
73
+ futures = [executor.submit(process_data_item, id) for id in batch_input_ids]
65
74
 
66
- for job in futures:
67
- job.result()
75
+ for job in futures:
76
+ job.result()
68
77
 
69
- return input_protos, annotation_protos
78
+ return input_protos, annotation_protos
@@ -11,50 +11,58 @@ from .base import ClarifaiDataLoader, ClarifaiDataset
11
11
 
12
12
 
13
13
  class TextClassificationDataset(ClarifaiDataset):
14
- """Upload text classification datasets to clarifai datasets"""
15
-
16
- def __init__(self,
17
- data_generator: Type[ClarifaiDataLoader],
18
- dataset_id: str,
19
- max_workers: int = 4) -> None:
20
- super().__init__(data_generator, dataset_id, max_workers)
21
-
22
- def _extract_protos(self, batch_input_ids: List[int]
23
- ) -> Tuple[List[resources_pb2.Input], List[resources_pb2.Annotation]]:
24
- """Create input image and annotation protos for batch of input ids.
25
- Args:
26
- batch_input_ids: List of input IDs to retrieve the protos for.
27
- Returns:
28
- input_protos: List of input protos.
29
- annotation_protos: List of annotation protos.
30
- """
31
- input_protos, annotation_protos = [], []
32
-
33
- def process_data_item(id):
34
- data_item = self.data_generator[id]
35
- metadata = Struct()
36
- text = data_item.text
37
- labels = data_item.labels if ((data_item.labels is None) or
38
- isinstance(data_item.labels, list)) else [data_item.labels
39
- ] # clarifai concept
40
- label_ids = data_item.label_ids
41
- input_id = f"{self.dataset_id}-{get_uuid(8)}" if data_item.id is None else f"{self.dataset_id}-{str(data_item.id)}"
42
- if data_item.metadata is not None:
43
- metadata.update(data_item.metadata)
44
-
45
- self.all_input_ids[id] = input_id
46
- input_protos.append(
47
- Inputs.get_text_input(
48
- input_id=input_id,
49
- raw_text=text,
50
- dataset_id=self.dataset_id,
51
- labels=labels,
52
- label_ids=label_ids,
53
- metadata=metadata))
54
-
55
- with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
56
- futures = [executor.submit(process_data_item, id) for id in batch_input_ids]
57
- for job in futures:
58
- job.result()
59
-
60
- return input_protos, annotation_protos
14
+ """Upload text classification datasets to clarifai datasets"""
15
+
16
+ def __init__(
17
+ self, data_generator: Type[ClarifaiDataLoader], dataset_id: str, max_workers: int = 4
18
+ ) -> None:
19
+ super().__init__(data_generator, dataset_id, max_workers)
20
+
21
+ def _extract_protos(
22
+ self, batch_input_ids: List[int]
23
+ ) -> Tuple[List[resources_pb2.Input], List[resources_pb2.Annotation]]:
24
+ """Create input image and annotation protos for batch of input ids.
25
+ Args:
26
+ batch_input_ids: List of input IDs to retrieve the protos for.
27
+ Returns:
28
+ input_protos: List of input protos.
29
+ annotation_protos: List of annotation protos.
30
+ """
31
+ input_protos, annotation_protos = [], []
32
+
33
+ def process_data_item(id):
34
+ data_item = self.data_generator[id]
35
+ metadata = Struct()
36
+ text = data_item.text
37
+ labels = (
38
+ data_item.labels
39
+ if ((data_item.labels is None) or isinstance(data_item.labels, list))
40
+ else [data_item.labels]
41
+ ) # clarifai concept
42
+ label_ids = data_item.label_ids
43
+ input_id = (
44
+ f"{self.dataset_id}-{get_uuid(8)}"
45
+ if data_item.id is None
46
+ else f"{self.dataset_id}-{str(data_item.id)}"
47
+ )
48
+ if data_item.metadata is not None:
49
+ metadata.update(data_item.metadata)
50
+
51
+ self.all_input_ids[id] = input_id
52
+ input_protos.append(
53
+ Inputs.get_text_input(
54
+ input_id=input_id,
55
+ raw_text=text,
56
+ dataset_id=self.dataset_id,
57
+ labels=labels,
58
+ label_ids=label_ids,
59
+ metadata=metadata,
60
+ )
61
+ )
62
+
63
+ with ThreadPoolExecutor(max_workers=self.max_workers) as executor:
64
+ futures = [executor.submit(process_data_item, id) for id in batch_input_ids]
65
+ for job in futures:
66
+ job.result()
67
+
68
+ return input_protos, annotation_protos