datamint 2.47.0__tar.gz → 2.48.0__tar.gz

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 (191) hide show
  1. {datamint-2.47.0 → datamint-2.48.0}/PKG-INFO +1 -1
  2. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/resources_api.py +1 -1
  3. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_import.py +11 -1
  4. {datamint-2.47.0 → datamint-2.48.0}/datamint/importers/_common.py +21 -8
  5. {datamint-2.47.0 → datamint-2.48.0}/datamint/importers/_detect.py +41 -11
  6. {datamint-2.47.0 → datamint-2.48.0}/datamint/importers/yolo.py +81 -53
  7. {datamint-2.47.0 → datamint-2.48.0}/pyproject.toml +1 -1
  8. {datamint-2.47.0 → datamint-2.48.0}/README.md +0 -0
  9. {datamint-2.47.0 → datamint-2.48.0}/datamint/__init__.py +0 -0
  10. {datamint-2.47.0 → datamint-2.48.0}/datamint/__main__.py +0 -0
  11. {datamint-2.47.0 → datamint-2.48.0}/datamint/_repr_utils.py +0 -0
  12. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/__init__.py +0 -0
  13. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/base_api.py +0 -0
  14. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/client.py +0 -0
  15. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/dto/__init__.py +0 -0
  16. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/dto/annotation_dto.py +0 -0
  17. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/dto/inference_prompts.py +0 -0
  18. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/dto/save_results_options.py +0 -0
  19. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/__init__.py +0 -0
  20. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/annotations_api.py +0 -0
  21. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/annotationsets_api.py +0 -0
  22. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/datasetsinfo_api.py +0 -0
  23. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/deploy_model_api.py +0 -0
  24. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/inference_api.py +0 -0
  25. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/model_types.py +0 -0
  26. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/models_api.py +0 -0
  27. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/pod_logs_api.py +0 -0
  28. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/projects_api.py +0 -0
  29. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/users_api.py +0 -0
  30. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/endpoints/validation_studies_api.py +0 -0
  31. {datamint-2.47.0 → datamint-2.48.0}/datamint/api/entity_base_api.py +0 -0
  32. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/__init__.py +0 -0
  33. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_config.py +0 -0
  34. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_download.py +0 -0
  35. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_example.py +0 -0
  36. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_inference.py +0 -0
  37. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_init.py +0 -0
  38. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_train.py +0 -0
  39. {datamint-2.47.0 → datamint-2.48.0}/datamint/client_cmd_tools/datamint_upload.py +0 -0
  40. {datamint-2.47.0 → datamint-2.48.0}/datamint/configs.py +0 -0
  41. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/__init__.py +0 -0
  42. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/annotation_processor.py +0 -0
  43. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/base.py +0 -0
  44. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/factory.py +0 -0
  45. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/image_dataset.py +0 -0
  46. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/multiframe_dataset.py +0 -0
  47. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/sliced_dataset.py +0 -0
  48. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/sliced_video_dataset.py +0 -0
  49. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/split_result.py +0 -0
  50. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/video_dataset.py +0 -0
  51. {datamint-2.47.0 → datamint-2.48.0}/datamint/dataset/volume_dataset.py +0 -0
  52. {datamint-2.47.0 → datamint-2.48.0}/datamint/default_project.py +0 -0
  53. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/__init__.py +0 -0
  54. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotation_worklist.py +0 -0
  55. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/__init__.py +0 -0
  56. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/annotation.py +0 -0
  57. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/annotation_spec.py +0 -0
  58. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/base_geometry.py +0 -0
  59. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/base_segmentation.py +0 -0
  60. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/box_annotation.py +0 -0
  61. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/category_annotation.py +0 -0
  62. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/geometry.py +0 -0
  63. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/image_classification.py +0 -0
  64. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/image_segmentation.py +0 -0
  65. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/label_annotation.py +0 -0
  66. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/line_annotation.py +0 -0
  67. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/numeric_annotation.py +0 -0
  68. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/point_annotation.py +0 -0
  69. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/region_annotation.py +0 -0
  70. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/text_annotation.py +0 -0
  71. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/types.py +0 -0
  72. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/annotations/volume_segmentation.py +0 -0
  73. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/base_entity.py +0 -0
  74. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/buildlog.py +0 -0
  75. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/cache_manager.py +0 -0
  76. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/channel.py +0 -0
  77. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/datasetinfo.py +0 -0
  78. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/deployjob.py +0 -0
  79. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/inferencejob.py +0 -0
  80. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/pod.py +0 -0
  81. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/project.py +0 -0
  82. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/project_resource_split.py +0 -0
  83. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/resource.py +0 -0
  84. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/resources/__init__.py +0 -0
  85. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/resources/dicom_resource.py +0 -0
  86. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/resources/image_resource.py +0 -0
  87. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/resources/nifti_resource.py +0 -0
  88. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/resources/video_resource.py +0 -0
  89. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/resources/volume_resource.py +0 -0
  90. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/sliced_resource.py +0 -0
  91. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/sliced_resource_base.py +0 -0
  92. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/sliced_video_resource.py +0 -0
  93. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/user.py +0 -0
  94. {datamint-2.47.0 → datamint-2.48.0}/datamint/entities/validation_study.py +0 -0
  95. {datamint-2.47.0 → datamint-2.48.0}/datamint/evaluate/__init__.py +0 -0
  96. {datamint-2.47.0 → datamint-2.48.0}/datamint/evaluate/evaluator.py +0 -0
  97. {datamint-2.47.0 → datamint-2.48.0}/datamint/evaluate/metrics/__init__.py +0 -0
  98. {datamint-2.47.0 → datamint-2.48.0}/datamint/evaluate/metrics/classification.py +0 -0
  99. {datamint-2.47.0 → datamint-2.48.0}/datamint/evaluate/metrics/detection.py +0 -0
  100. {datamint-2.47.0 → datamint-2.48.0}/datamint/evaluate/metrics/segmentation.py +0 -0
  101. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/__init__.py +0 -0
  102. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/_common.py +0 -0
  103. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/_download.py +0 -0
  104. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/bccd_dataset.py +0 -0
  105. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/busi_dataset.py +0 -0
  106. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/example_projects.py +0 -0
  107. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/fracatlas_dataset.py +0 -0
  108. {datamint-2.47.0 → datamint-2.48.0}/datamint/examples/synapse_dataset.py +0 -0
  109. {datamint-2.47.0 → datamint-2.48.0}/datamint/exceptions.py +0 -0
  110. {datamint-2.47.0 → datamint-2.48.0}/datamint/importers/__init__.py +0 -0
  111. {datamint-2.47.0 → datamint-2.48.0}/datamint/importers/coco.py +0 -0
  112. {datamint-2.47.0 → datamint-2.48.0}/datamint/importers/pascal_voc.py +0 -0
  113. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/__init__.py +0 -0
  114. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/benchmark.py +0 -0
  115. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/datamodule.py +0 -0
  116. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/__init__.py +0 -0
  117. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/base_trainer.py +0 -0
  118. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/classification_trainer.py +0 -0
  119. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/detection_trainer.py +0 -0
  120. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/__init__.py +0 -0
  121. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/base.py +0 -0
  122. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/classification_module.py +0 -0
  123. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/detection_modules/__init__.py +0 -0
  124. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/detection_modules/yolox_module.py +0 -0
  125. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/segmentation_module.py +0 -0
  126. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/segmentation_modules/__init__.py +0 -0
  127. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/segmentation_modules/deeplabv3plus.py +0 -0
  128. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/segmentation_modules/smp_module.py +0 -0
  129. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/segmentation_modules/transunet.py +0 -0
  130. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/segmentation_modules/unetpp.py +0 -0
  131. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/lightning_modules/segmentation_modules/unetrpp.py +0 -0
  132. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/seg2d_trainer.py +0 -0
  133. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/seg3d_trainer.py +0 -0
  134. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/segmentation_trainer.py +0 -0
  135. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/__init__.py +0 -0
  136. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/deeplabv3plus.py +0 -0
  137. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/efficientnetv2.py +0 -0
  138. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/nnunet/__init__.py +0 -0
  139. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/nnunet/_nnunet_trainer_bridge.py +0 -0
  140. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/nnunet/data_export.py +0 -0
  141. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/nnunet/data_import.py +0 -0
  142. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/nnunet/inference_model.py +0 -0
  143. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/nnunet/trainer.py +0 -0
  144. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/transunet.py +0 -0
  145. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/unetpp.py +0 -0
  146. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/unetrpp.py +0 -0
  147. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/specialized/yolox.py +0 -0
  148. {datamint-2.47.0 → datamint-2.48.0}/datamint/lightning/trainers/vol_seg_trainer.py +0 -0
  149. {datamint-2.47.0 → datamint-2.48.0}/datamint/logging.yaml +0 -0
  150. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/__init__.py +0 -0
  151. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/artifact/__init__.py +0 -0
  152. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/artifact/datamint_artifacts_repo.py +0 -0
  153. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/data/__init__.py +0 -0
  154. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/data/datamint_dataset.py +0 -0
  155. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/env_utils.py +0 -0
  156. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/env_vars.py +0 -0
  157. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/__init__.py +0 -0
  158. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/annotation_specs.py +0 -0
  159. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/datamint_flavor.py +0 -0
  160. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/model.py +0 -0
  161. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/model_loader.py +0 -0
  162. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/model_parser.py +0 -0
  163. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/prediction_modes.py +0 -0
  164. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/prediction_router.py +0 -0
  165. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/task_type.py +0 -0
  166. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/flavors/validation.py +0 -0
  167. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/lightning/callbacks/__init__.py +0 -0
  168. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/lightning/callbacks/modelcheckpoint.py +0 -0
  169. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/models/Dockerfile.template +0 -0
  170. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/models/__init__.py +0 -0
  171. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/models/datamint_model_store.py +0 -0
  172. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/models/docker_build.py +0 -0
  173. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/models/local_inference.py +0 -0
  174. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/models/serve.py +0 -0
  175. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/models/tags.py +0 -0
  176. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/store_utils.py +0 -0
  177. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/tracking/datamint_store.py +0 -0
  178. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/tracking/default_experiment.py +0 -0
  179. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/tracking/fluent.py +0 -0
  180. {datamint-2.47.0 → datamint-2.48.0}/datamint/mlflow/tracking/offline_buffer.py +0 -0
  181. {datamint-2.47.0 → datamint-2.48.0}/datamint/types.py +0 -0
  182. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/annotation_agreement.py +0 -0
  183. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/collection_utils.py +0 -0
  184. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/date_utils.py +0 -0
  185. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/env.py +0 -0
  186. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/logging_utils.py +0 -0
  187. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/nifti_utils.py +0 -0
  188. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/torchmetrics.py +0 -0
  189. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/uncertainty.py +0 -0
  190. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/urls.py +0 -0
  191. {datamint-2.47.0 → datamint-2.48.0}/datamint/utils/visualization.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datamint
3
- Version: 2.47.0
3
+ Version: 2.48.0
4
4
  Summary: A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows.
5
5
  Keywords: medical-imaging,dicom,nifti,pytorch,mlflow,lightning,datasets,annotation
6
6
  Author: SonanceAI
@@ -637,7 +637,7 @@ class ResourcesApi(CreatableEntityApi[Resource], DeletableEntityApi[Resource]):
637
637
  await self.annotations_api._upload_segmentations_async(
638
638
  resource_id,
639
639
  file_path=f,
640
- name=name,
640
+ name=self.annotations_api.standardize_segmentation_names(name),
641
641
  frame_index=frame_index,
642
642
  transpose_segmentation=transpose_segmentation,
643
643
  model_id=model_name,
@@ -132,7 +132,8 @@ def _resolve_dataset(args: argparse.Namespace) -> tuple[DatasetFormat, dict]:
132
132
 
133
133
  _USER_LOGGER.info(f"Detected a {fmt.upper()} dataset under '{path}':")
134
134
  for key, value in base_kwargs.items():
135
- _USER_LOGGER.info(f' {key}: {value}')
135
+ for v in (value if isinstance(value, list) else [value]):
136
+ _USER_LOGGER.info(f' {key}: {v}')
136
137
  if not args.yes:
137
138
  answer = input(f'Import as {fmt.upper()}? (y/n): ')
138
139
  if answer.strip().lower() != 'y':
@@ -161,6 +162,15 @@ def _resolve_dataset(args: argparse.Namespace) -> tuple[DatasetFormat, dict]:
161
162
  f'Pass {flags} explicitly.'
162
163
  )
163
164
 
165
+ if fmt == 'yolo':
166
+ n_images, n_labels = (len(v) if isinstance(v, list) else 1
167
+ for v in (base_kwargs['images_dir'], base_kwargs['labels_dir']))
168
+ if n_images != n_labels:
169
+ raise DatamintException(
170
+ f'Detected {max(n_images, n_labels)} YOLO splits under \'{path}\', so a single '
171
+ '--images-dir or --labels-dir is ambiguous. Pass both --images-dir and --labels-dir.'
172
+ )
173
+
164
174
  return fmt, base_kwargs
165
175
 
166
176
 
@@ -19,12 +19,14 @@ def import_boxes_to_project(result,
19
19
  imported_from: str,
20
20
  on_error: Literal['raise', 'skip'],
21
21
  progress_bar: bool,
22
- result_cls: type):
22
+ result_cls: type,
23
+ sample_tags: Callable[[object], Sequence[str]] | None = None):
23
24
  """Shared upload loop behind every ``*Importer.import_to_project()``.
24
25
 
25
26
  ``result`` is a parse result with ``samples``, ``missing_images``, and
26
27
  ``unsupported_annotations`` attributes. ``box_points`` maps a format's box
27
28
  dataclass to a ``(point1, point2)`` pair for ``add_box_annotation``.
29
+ ``sample_tags`` gives extra tags per sample (e.g. its split), added to ``tags``.
28
30
 
29
31
  """
30
32
  api = api or Api()
@@ -37,13 +39,24 @@ def import_boxes_to_project(result,
37
39
  f'unsupported annotation type (e.g. polygon/segmentation) and were not '
38
40
  f'imported; only bounding boxes are supported.')
39
41
 
40
- uploaded = api.resources.upload_resources(
41
- [str(s.image_path) for s in result.samples],
42
- tags=tags,
43
- publish_to=project,
44
- on_error=on_error,
45
- progress_bar=progress_bar,
46
- )
42
+ # upload_resources applies one tag list to all files, so samples are uploaded in groups of equal tags
43
+ groups: dict[tuple[str, ...], list[int]] = {}
44
+ for i, sample in enumerate(result.samples):
45
+ extra = tuple(sample_tags(sample)) if sample_tags is not None else ()
46
+ groups.setdefault(extra, []).append(i)
47
+
48
+ uploaded: list = [None] * len(result.samples)
49
+ for extra, idxs in groups.items():
50
+ group_tags = list(tags or []) + list(extra)
51
+ group_ids = api.resources.upload_resources(
52
+ [str(result.samples[i].image_path) for i in idxs],
53
+ tags=group_tags or None,
54
+ publish_to=project,
55
+ on_error=on_error,
56
+ progress_bar=progress_bar,
57
+ )
58
+ for i, resource_id in zip(idxs, group_ids):
59
+ uploaded[i] = resource_id
47
60
 
48
61
  resource_ids: list[str] = []
49
62
  errors: list[tuple[str, Exception]] = []
@@ -15,6 +15,7 @@ from typing import Literal
15
15
  DatasetFormat = Literal['coco', 'yolo', 'pascal_voc']
16
16
 
17
17
  _IMAGE_DIR_NAMES = {'images', 'image', 'imgs', 'jpegimages', 'img'}
18
+ _LABEL_DIR_NAMES = {'labels', 'label'}
18
19
 
19
20
 
20
21
  @dataclass
@@ -22,7 +23,7 @@ class DetectedDataset:
22
23
  """Result of a format sniff: which format, and the constructor kwargs
23
24
  to feed the matching ``*Importer``."""
24
25
  format: DatasetFormat
25
- importer_kwargs: dict[str, Path] = field(default_factory=dict)
26
+ importer_kwargs: dict[str, Path | list[Path]] = field(default_factory=dict)
26
27
 
27
28
 
28
29
  def _find_dir(root: Path, names: set[str]) -> Path | None:
@@ -61,19 +62,48 @@ def sniff_pascal_voc(root: Path) -> DetectedDataset | None:
61
62
  return None
62
63
 
63
64
 
65
+ def _is_yolo_labels_dir(path: Path) -> bool:
66
+ txt_paths = [p for p in sorted(path.glob('*.txt')) if p.name != 'classes.txt']
67
+ for txt_path in txt_paths[:5]:
68
+ values = txt_path.read_text().split()
69
+ # YOLO box line: class cx cy w h
70
+ if values and len(values) % 5 == 0:
71
+ return True
72
+ return False
73
+
74
+
75
+ def _yolo_images_dir(labels_dir: Path) -> Path:
76
+ """Swap the last ``labels`` component of the path for its sibling images dir
77
+ (``train/labels`` -> ``train/images``, ``labels/train`` -> ``images/train``)."""
78
+ parts = labels_dir.parts
79
+ for i in reversed(range(len(parts))):
80
+ if parts[i].lower() not in _LABEL_DIR_NAMES:
81
+ continue
82
+ for sibling in sorted(Path(*parts[:i]).iterdir()):
83
+ candidate = sibling.joinpath(*parts[i + 1:])
84
+ if sibling.is_dir() and sibling.name.lower() in _IMAGE_DIR_NAMES and candidate.is_dir():
85
+ return candidate
86
+ break
87
+ return labels_dir.parent / 'images'
88
+
89
+
64
90
  def sniff_yolo(root: Path) -> DetectedDataset | None:
65
- """Look for a ``labels/`` dir of YOLO ``.txt`` files (class + 4 normalized floats)."""
66
- labels_dir = _find_dir(root, {'labels', 'label'})
67
- if labels_dir is None:
68
- return None
69
- txt_paths = [p for p in sorted(labels_dir.glob('*.txt')) if p.name != 'classes.txt']
70
- if not txt_paths:
71
- return None
72
- if not any(len(p.read_text().split()) % 5 == 0 and p.read_text().strip() for p in txt_paths[:5]):
91
+ """Look for ``labels/`` dirs of YOLO ``.txt`` files (class + 4 normalized floats).
92
+
93
+ Every split (``train``, ``valid``, ``test``, ...) is picked up, each paired with its images dir.
94
+ """
95
+ labels_dirs = [p for p in sorted(root.rglob('*'))
96
+ if p.is_dir()
97
+ and any(part.lower() in _LABEL_DIR_NAMES for part in p.relative_to(root).parts)
98
+ and _is_yolo_labels_dir(p)]
99
+ if not labels_dirs:
73
100
  return None
74
101
 
75
- images_dir = _find_dir(root, _IMAGE_DIR_NAMES) or labels_dir.parent / 'images'
76
- kwargs: dict[str, Path] = {'images_dir': images_dir, 'labels_dir': labels_dir}
102
+ images_dirs = [_yolo_images_dir(p) for p in labels_dirs]
103
+ kwargs: dict[str, Path | list[Path]] = {
104
+ 'images_dir': images_dirs[0] if len(images_dirs) == 1 else images_dirs,
105
+ 'labels_dir': labels_dirs[0] if len(labels_dirs) == 1 else labels_dirs,
106
+ }
77
107
 
78
108
  data_yaml = next(root.glob('*.yaml'), None) or next(root.glob('*.yml'), None)
79
109
  if data_yaml is not None:
@@ -9,6 +9,7 @@ from datamint import Api
9
9
  from datamint.entities import Project
10
10
 
11
11
  from . import _common
12
+ from ._detect import _LABEL_DIR_NAMES
12
13
 
13
14
  _DEFAULT_IMAGE_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.bmp', '.tif', '.tiff', '.webp')
14
15
 
@@ -27,6 +28,7 @@ class YOLOSample:
27
28
  image_path: Path
28
29
  file_name: str
29
30
  boxes: list[YOLOBox] = field(default_factory=list)
31
+ split: str | None = None
30
32
 
31
33
 
32
34
  @dataclass
@@ -67,21 +69,43 @@ def _load_names_from_yaml(path: Path) -> dict[int, str]:
67
69
  return {idx: str(name) for idx, name in enumerate(names)}
68
70
 
69
71
 
72
+ def _as_paths(value: str | Path | Sequence[str | Path]) -> list[Path]:
73
+ if isinstance(value, (str, Path)):
74
+ return [Path(value)]
75
+ return [Path(v) for v in value]
76
+
77
+
78
+ def _split_name(labels_dir: Path) -> str:
79
+ """``train/labels`` -> ``train``, ``labels/train`` -> ``train``."""
80
+ parts = labels_dir.parts
81
+ idxs = [i for i, part in enumerate(parts) if part.lower() in _LABEL_DIR_NAMES]
82
+ if not idxs:
83
+ return labels_dir.name
84
+ idx = idxs[-1]
85
+ return parts[idx + 1] if idx + 1 < len(parts) else parts[idx - 1]
86
+
87
+
70
88
  class YOLOImporter:
71
89
  """Parse a YOLO-format (images + normalized-bbox label .txt files) dataset and
72
90
  upload it to a Datamint project.
73
91
 
92
+ ``images_dir`` and ``labels_dir`` take one dir each, or one per split, paired by position.
93
+ With several splits, each resource is tagged ``split:<name>`` (e.g. ``split:train``).
74
94
  """
75
95
 
76
96
  def __init__(self,
77
- images_dir: str | Path,
78
- labels_dir: str | Path,
97
+ images_dir: str | Path | Sequence[str | Path],
98
+ labels_dir: str | Path | Sequence[str | Path],
79
99
  *,
80
100
  class_names: Sequence[str] | None = None,
81
101
  data_yaml: str | Path | None = None,
82
102
  image_extensions: Sequence[str] = _DEFAULT_IMAGE_EXTENSIONS):
83
- self.images_dir = Path(images_dir)
84
- self.labels_dir = Path(labels_dir)
103
+ images_dirs = _as_paths(images_dir)
104
+ labels_dirs = _as_paths(labels_dir)
105
+ if len(images_dirs) != len(labels_dirs):
106
+ raise ValueError(f'images_dir and labels_dir must have the same number of entries '
107
+ f'(got {len(images_dirs)} and {len(labels_dirs)}).')
108
+ self.splits = list(zip(images_dirs, labels_dirs))
85
109
  self.class_names_override = list(class_names) if class_names is not None else None
86
110
  self.data_yaml = Path(data_yaml) if data_yaml is not None else None
87
111
  self.image_extensions = image_extensions
@@ -96,9 +120,9 @@ class YOLOImporter:
96
120
 
97
121
  raise ValueError('No class names available: pass class_names or data_yaml explicitly.')
98
122
 
99
- def _find_image(self, stem: str) -> Path | None:
123
+ def _find_image(self, images_dir: Path, stem: str) -> Path | None:
100
124
  for ext in self.image_extensions:
101
- candidate = self.images_dir / f'{stem}{ext}'
125
+ candidate = images_dir / f'{stem}{ext}'
102
126
  if candidate.exists():
103
127
  return candidate
104
128
  return None
@@ -123,52 +147,55 @@ class YOLOImporter:
123
147
  used_class_names: set[str] = set()
124
148
  unsupported_annotations = 0
125
149
 
126
- for txt_path in sorted(self.labels_dir.glob('*.txt')):
127
- if txt_path.name in ('classes.txt',):
128
- continue
129
-
130
- image_path = self._find_image(txt_path.stem)
131
- if image_path is None:
132
- missing_images.append(txt_path.name)
133
- continue
134
-
135
- img_w, img_h = Image.open(image_path).size
136
-
137
- sample = YOLOSample(image_path=image_path, file_name=image_path.name)
138
- with open(txt_path) as f:
139
- for line in f:
140
- parts = line.split()
141
- if not parts:
142
- continue
143
- if len(parts) != 5:
144
- # segmentation/OBB/keypoint variants have a different field count -- not supported
145
- unsupported_annotations += 1
146
- continue
147
-
148
- class_id = int(parts[0])
149
- if class_id not in class_names_by_id:
150
- raise ValueError(f"Label '{txt_path}' references unknown class_id {class_id}.")
151
-
152
- cx, cy, w, h = (float(v) for v in parts[1:])
153
- for coord_name, value in (('x_center', cx), ('y_center', cy), ('width', w), ('height', h)):
154
- if not (0.0 <= value <= 1.0):
155
- raise ValueError(f"Label '{txt_path}' has out-of-range normalized "
156
- f"{coord_name}={value!r} (expected 0<=v<=1).")
157
-
158
- cx, w = cx * img_w, w * img_w
159
- cy, h = cy * img_h, h * img_h
160
-
161
- label = class_names_by_id[class_id]
162
- sample.boxes.append(YOLOBox(
163
- label=label,
164
- x1=cx - w / 2,
165
- y1=cy - h / 2,
166
- x2=cx + w / 2,
167
- y2=cy + h / 2,
168
- ))
169
- used_class_names.add(label)
170
-
171
- samples.append(sample)
150
+ tag_splits = len(self.splits) > 1
151
+ for images_dir, labels_dir in self.splits:
152
+ split = _split_name(labels_dir) if tag_splits else None
153
+ for txt_path in sorted(labels_dir.glob('*.txt')):
154
+ if txt_path.name in ('classes.txt',):
155
+ continue
156
+
157
+ image_path = self._find_image(images_dir, txt_path.stem)
158
+ if image_path is None:
159
+ missing_images.append(txt_path.name)
160
+ continue
161
+
162
+ img_w, img_h = Image.open(image_path).size
163
+
164
+ sample = YOLOSample(image_path=image_path, file_name=image_path.name, split=split)
165
+ with open(txt_path) as f:
166
+ for line in f:
167
+ parts = line.split()
168
+ if not parts:
169
+ continue
170
+ if len(parts) != 5:
171
+ # segmentation/OBB/keypoint variants have a different field count -- not supported
172
+ unsupported_annotations += 1
173
+ continue
174
+
175
+ class_id = int(parts[0])
176
+ if class_id not in class_names_by_id:
177
+ raise ValueError(f"Label '{txt_path}' references unknown class_id {class_id}.")
178
+
179
+ cx, cy, w, h = (float(v) for v in parts[1:])
180
+ for coord_name, value in (('x_center', cx), ('y_center', cy), ('width', w), ('height', h)):
181
+ if not (0.0 <= value <= 1.0):
182
+ raise ValueError(f"Label '{txt_path}' has out-of-range normalized "
183
+ f"{coord_name}={value!r} (expected 0<=v<=1).")
184
+
185
+ cx, w = cx * img_w, w * img_w
186
+ cy, h = cy * img_h, h * img_h
187
+
188
+ label = class_names_by_id[class_id]
189
+ sample.boxes.append(YOLOBox(
190
+ label=label,
191
+ x1=cx - w / 2,
192
+ y1=cy - h / 2,
193
+ x2=cx + w / 2,
194
+ y2=cy + h / 2,
195
+ ))
196
+ used_class_names.add(label)
197
+
198
+ samples.append(sample)
172
199
 
173
200
  self._result = YOLOParseResult(
174
201
  samples=samples,
@@ -195,7 +222,8 @@ class YOLOImporter:
195
222
  return _common.import_boxes_to_project(
196
223
  result, project, api,
197
224
  box_points=lambda b: ((b.x1, b.y1), (b.x2, b.y2)),
198
- source_label=str(self.labels_dir),
225
+ source_label=', '.join(str(labels_dir) for _, labels_dir in self.splits),
226
+ sample_tags=lambda s: [f'split:{s.split}'] if s.split else [],
199
227
  tags=tags,
200
228
  imported_from=imported_from,
201
229
  on_error=on_error,
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "datamint"
3
3
  description = "A library for interacting with the Datamint API, designed for efficient data management, processing and Deep Learning workflows."
4
- version = "2.47.0"
4
+ version = "2.48.0"
5
5
  dynamic = ["dependencies"]
6
6
  requires-python = ">=3.10"
7
7
  readme = "README.md"
File without changes
File without changes
File without changes