datamint 2.52.0__tar.gz → 2.53.1__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.
- {datamint-2.52.0 → datamint-2.53.1}/PKG-INFO +1 -1
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/base_segmentation.py +30 -7
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/resource.py +2 -1
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/datamint_flavor.py +38 -2
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/visualization.py +3 -1
- {datamint-2.52.0 → datamint-2.53.1}/pyproject.toml +1 -1
- {datamint-2.52.0 → datamint-2.53.1}/README.md +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/__main__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/_repr_utils.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/base_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/client.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/dto/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/dto/annotation_dto.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/dto/inference_prompts.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/dto/save_results_options.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/annotations_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/annotationsets_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/datasetsinfo_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/deploy_model_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/inference_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/model_types.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/models_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/pod_logs_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/projects_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/resources_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/users_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/endpoints/validation_studies_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/api/entity_base_api.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_config.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_download.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_example.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_import.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_inference.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_init.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_train.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/client_cmd_tools/datamint_upload.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/configs.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/annotation_processor.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/base.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/factory.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/image_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/multiframe_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/sliced_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/sliced_video_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/split_result.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/video_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/dataset/volume_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/default_project.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotation_worklist.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/annotation_spec.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/base_geometry.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/box_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/category_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/geometry.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/image_classification.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/image_segmentation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/label_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/line_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/numeric_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/point_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/region_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/text_annotation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/types.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/annotations/volume_segmentation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/base_entity.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/buildlog.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/cache_manager.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/channel.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/datasetinfo.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/deployjob.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/inferencejob.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/pod.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/project.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/project_resource_split.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/resources/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/resources/dicom_resource.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/resources/image_resource.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/resources/nifti_resource.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/resources/video_resource.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/resources/volume_resource.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/sliced_resource.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/sliced_resource_base.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/sliced_video_resource.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/user.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/entities/validation_study.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/evaluate/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/evaluate/evaluator.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/evaluate/metrics/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/evaluate/metrics/classification.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/evaluate/metrics/detection.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/evaluate/metrics/segmentation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/_common.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/_download.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/bccd_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/busi_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/example_projects.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/fracatlas_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/examples/synapse_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/exceptions.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/importers/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/importers/_common.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/importers/_detect.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/importers/coco.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/importers/pascal_voc.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/importers/yolo.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/benchmark.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/datamodule.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/base_trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/classification_trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/detection_trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/base.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/classification_module.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/detection_modules/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/detection_modules/yolox_module.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/segmentation_module.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/segmentation_modules/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/segmentation_modules/deeplabv3plus.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/segmentation_modules/smp_module.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/segmentation_modules/transunet.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/segmentation_modules/unetpp.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/segmentation_modules/unetrpp.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/seg2d_trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/seg3d_trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/segmentation_trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/deeplabv3plus.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/efficientnetv2.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/_nnunet_trainer_bridge.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/data_export.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/data_import.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/inference_model.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/transunet.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/unetpp.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/unetrpp.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/yolox.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/vol_seg_trainer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/logging.yaml +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/artifact/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/artifact/datamint_artifacts_repo.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/data/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/data/datamint_dataset.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/env_utils.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/env_vars.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/annotation_specs.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/model.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/model_loader.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/model_parser.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/prediction_modes.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/prediction_router.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/task_type.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/flavors/validation.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/lightning/callbacks/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/lightning/callbacks/modelcheckpoint.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/models/Dockerfile.template +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/models/__init__.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/models/datamint_model_store.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/models/docker_build.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/models/local_inference.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/models/serve.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/models/tags.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/store_utils.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/tracking/datamint_store.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/tracking/default_experiment.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/tracking/fluent.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/mlflow/tracking/offline_buffer.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/types.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/annotation_agreement.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/collection_utils.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/date_utils.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/env.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/logging_utils.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/nifti_utils.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/torchmetrics.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/uncertainty.py +0 -0
- {datamint-2.52.0 → datamint-2.53.1}/datamint/utils/urls.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datamint
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.53.1
|
|
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
|
|
@@ -93,22 +93,35 @@ def _serialize_segmentation_data(
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
if serialize_as_mimetype == "application/nifti":
|
|
96
|
+
transposed_2d = False
|
|
96
97
|
if isinstance(value, np.ndarray):
|
|
97
|
-
value
|
|
98
|
+
if value.ndim == 2:
|
|
99
|
+
value = Nifti1Image(value.T, affine=np.eye(4))
|
|
100
|
+
transposed_2d = True
|
|
101
|
+
else:
|
|
102
|
+
value = Nifti1Image(value, affine=np.eye(4))
|
|
98
103
|
elif isinstance(value, Image.Image):
|
|
99
|
-
|
|
104
|
+
arr = np.array(value)
|
|
105
|
+
if arr.ndim == 2:
|
|
106
|
+
value = Nifti1Image(arr.T, affine=np.eye(4))
|
|
107
|
+
transposed_2d = True
|
|
108
|
+
else:
|
|
109
|
+
value = Nifti1Image(arr, affine=np.eye(4))
|
|
100
110
|
elif not isinstance(value, Nifti1Image):
|
|
101
111
|
raise TypeError(
|
|
102
112
|
f"Cannot serialise {type(value)} as application/nifti; "
|
|
103
113
|
"expected np.ndarray, PIL.Image.Image or Nifti1Image"
|
|
104
114
|
)
|
|
105
115
|
|
|
106
|
-
|
|
116
|
+
result: dict[str, Any] = {
|
|
107
117
|
"mimetype": "application/nifti",
|
|
108
118
|
"data": base64.b64encode(gzip.compress(value.to_bytes())).decode("ascii"),
|
|
109
119
|
"compressed": True,
|
|
110
120
|
"type": original_type,
|
|
111
121
|
}
|
|
122
|
+
if transposed_2d:
|
|
123
|
+
result["axis_order"] = "wh"
|
|
124
|
+
return result
|
|
112
125
|
|
|
113
126
|
if serialize_as_mimetype is not None and serialize_as_mimetype != 'auto':
|
|
114
127
|
raise ValueError(f"Unsupported serialize_as_mimetype: {serialize_as_mimetype!r}")
|
|
@@ -211,17 +224,25 @@ def _deserialize_segmentation_data(
|
|
|
211
224
|
if target_type == "nifti" and isinstance(decoded, Nifti1Image):
|
|
212
225
|
return decoded
|
|
213
226
|
|
|
227
|
+
axis_order = value.get("axis_order")
|
|
228
|
+
|
|
214
229
|
if target_type == "ndarray":
|
|
215
230
|
if isinstance(decoded, Image.Image):
|
|
216
231
|
return np.array(decoded)
|
|
217
232
|
if isinstance(decoded, Nifti1Image):
|
|
218
|
-
|
|
233
|
+
arr = np.asarray(decoded.dataobj)
|
|
234
|
+
if axis_order == "wh" and arr.ndim == 2:
|
|
235
|
+
arr = arr.T
|
|
236
|
+
return arr
|
|
219
237
|
|
|
220
238
|
if target_type == "pil":
|
|
221
239
|
if isinstance(decoded, np.ndarray):
|
|
222
240
|
return Image.fromarray(decoded)
|
|
223
241
|
if isinstance(decoded, Nifti1Image):
|
|
224
|
-
|
|
242
|
+
arr = np.asarray(decoded.dataobj)
|
|
243
|
+
if axis_order == "wh" and arr.ndim == 2:
|
|
244
|
+
arr = arr.T
|
|
245
|
+
return Image.fromarray(np.squeeze(arr))
|
|
225
246
|
|
|
226
247
|
if target_type == "nifti":
|
|
227
248
|
if isinstance(decoded, np.ndarray):
|
|
@@ -414,13 +435,15 @@ class BaseSegmentationAnnotation(Annotation):
|
|
|
414
435
|
def _to_raw_bytes(data: np.ndarray | Image.Image | Any) -> bytes:
|
|
415
436
|
"""Encode *data* to bytes suitable for file storage.
|
|
416
437
|
|
|
417
|
-
* ``np.ndarray`` → NIfTI bytes (wrapped with identity affine
|
|
438
|
+
* ``np.ndarray`` → NIfTI bytes (wrapped with identity affine; 2D
|
|
439
|
+
``(H, W)`` arrays are transposed to standard NIfTI ``(W, H)`` order).
|
|
418
440
|
* ``PIL.Image`` → PNG bytes.
|
|
419
441
|
* ``Nifti1Image`` → NIfTI bytes.
|
|
420
442
|
"""
|
|
421
443
|
if isinstance(data, np.ndarray):
|
|
422
444
|
from nibabel.nifti1 import Nifti1Image
|
|
423
|
-
|
|
445
|
+
nifti_data = data.T if data.ndim == 2 else data
|
|
446
|
+
return Nifti1Image(nifti_data, affine=np.eye(4)).to_bytes()
|
|
424
447
|
|
|
425
448
|
if isinstance(data, Image.Image):
|
|
426
449
|
buf = io.BytesIO()
|
|
@@ -629,6 +629,7 @@ class Resource(BaseResource):
|
|
|
629
629
|
webbrowser.open(self.url)
|
|
630
630
|
|
|
631
631
|
def plot_segmentations(self,
|
|
632
|
+
anns: Sequence['Annotation'] | None = None,
|
|
632
633
|
index: int | None = None,
|
|
633
634
|
axis: 'ViewPlane' = 'axial',
|
|
634
635
|
alpha: float = 0.5,
|
|
@@ -639,7 +640,7 @@ class Resource(BaseResource):
|
|
|
639
640
|
"""
|
|
640
641
|
from datamint.utils.visualization import plot_segmentations
|
|
641
642
|
|
|
642
|
-
return plot_segmentations(self, index=index, axis=axis, alpha=alpha, ax=ax)
|
|
643
|
+
return plot_segmentations(self, anns=anns, index=index, axis=axis, alpha=alpha, ax=ax)
|
|
643
644
|
|
|
644
645
|
def plot_shapes(self,
|
|
645
646
|
axis: 'ViewPlane | None' = None,
|
|
@@ -11,6 +11,7 @@ from mlflow import pyfunc
|
|
|
11
11
|
from mlflow.models import Model, ModelInputExample, ModelSignature
|
|
12
12
|
from mlflow.pytorch import pickle_module as mlflow_pytorch_pickle_module
|
|
13
13
|
from packaging.requirements import Requirement
|
|
14
|
+
from packaging.utils import canonicalize_name
|
|
14
15
|
|
|
15
16
|
import datamint
|
|
16
17
|
import datamint.mlflow.flavors
|
|
@@ -245,6 +246,37 @@ def _resolve_requirements(
|
|
|
245
246
|
return pip_requirements, extra_pip_requirements, extra_artifacts
|
|
246
247
|
|
|
247
248
|
|
|
249
|
+
# installed in notebook environments (e.g. Colab), so MLflow may infer them, but they're never needed for
|
|
250
|
+
# inference and some can't be installed in the deploy image (google-colab only supports Python < 3.11)
|
|
251
|
+
_NOTEBOOK_ONLY_PACKAGES = {'google-colab', 'ipykernel', 'ipython'}
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def _is_notebook_only(req: str) -> bool:
|
|
255
|
+
try:
|
|
256
|
+
return canonicalize_name(Requirement(req).name) in _NOTEBOOK_ONLY_PACKAGES
|
|
257
|
+
except Exception:
|
|
258
|
+
return False
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def _drop_notebook_requirements(path) -> None:
|
|
262
|
+
"""Remove notebook-only packages from the requirements MLflow wrote to the model directory """
|
|
263
|
+
import yaml
|
|
264
|
+
|
|
265
|
+
path = Path(path)
|
|
266
|
+
req_file = path / 'requirements.txt'
|
|
267
|
+
if req_file.exists():
|
|
268
|
+
lines = req_file.read_text().splitlines()
|
|
269
|
+
req_file.write_text(''.join(f'{line}\n' for line in lines if not _is_notebook_only(line)))
|
|
270
|
+
|
|
271
|
+
conda_file = path / 'conda.yaml'
|
|
272
|
+
if conda_file.exists():
|
|
273
|
+
env = yaml.safe_load(conda_file.read_text())
|
|
274
|
+
for dep in env.get('dependencies', []):
|
|
275
|
+
if isinstance(dep, dict) and 'pip' in dep:
|
|
276
|
+
dep['pip'] = [r for r in dep['pip'] if not _is_notebook_only(r)]
|
|
277
|
+
conda_file.write_text(yaml.safe_dump(env, default_flow_style=False, sort_keys=False))
|
|
278
|
+
|
|
279
|
+
|
|
248
280
|
def save_model(datamint_model: BaseDatamintModel,
|
|
249
281
|
path,
|
|
250
282
|
task_type: TaskType | str | None = None,
|
|
@@ -351,10 +383,12 @@ def save_model(datamint_model: BaseDatamintModel,
|
|
|
351
383
|
datamint_model.__class__.__name__,
|
|
352
384
|
)
|
|
353
385
|
try:
|
|
354
|
-
|
|
386
|
+
result = mlflow.pyfunc.save_model(**pyfunc_kwargs)
|
|
355
387
|
finally:
|
|
356
388
|
for d in _wheel_tmpdirs:
|
|
357
389
|
_shutil.rmtree(d, ignore_errors=True)
|
|
390
|
+
_drop_notebook_requirements(path)
|
|
391
|
+
return result
|
|
358
392
|
|
|
359
393
|
# DatamintLightningModule is an nn.Module itself, so its CUDA weights are
|
|
360
394
|
# embedded directly in the cloudpickle. Move to CPU before serialization
|
|
@@ -370,10 +404,12 @@ def save_model(datamint_model: BaseDatamintModel,
|
|
|
370
404
|
|
|
371
405
|
logger.debug(f'Saving PyFunc model for model {datamint_model.__class__.__name__}...')
|
|
372
406
|
try:
|
|
373
|
-
|
|
407
|
+
result = mlflow.pyfunc.save_model(**pyfunc_kwargs)
|
|
374
408
|
finally:
|
|
375
409
|
for d in _wheel_tmpdirs:
|
|
376
410
|
_shutil.rmtree(d, ignore_errors=True)
|
|
411
|
+
_drop_notebook_requirements(path)
|
|
412
|
+
return result
|
|
377
413
|
|
|
378
414
|
|
|
379
415
|
def log_model(
|
|
@@ -229,6 +229,7 @@ def _plot_title(resource: 'Resource', axis: 'ViewPlane | None', index: int) -> s
|
|
|
229
229
|
|
|
230
230
|
|
|
231
231
|
def plot_segmentations(resource: 'Resource',
|
|
232
|
+
anns: Sequence['Annotation'] | None = None,
|
|
232
233
|
index: int | None = None,
|
|
233
234
|
axis: 'ViewPlane' = 'axial',
|
|
234
235
|
alpha: float = 0.5,
|
|
@@ -240,7 +241,8 @@ def plot_segmentations(resource: 'Resource',
|
|
|
240
241
|
vol, _, std_axis = _read_volume(resource, axis)
|
|
241
242
|
seg_axis = 0 if std_axis == 0 else std_axis - 1 # masks are (N, H, W), without the channel axis
|
|
242
243
|
|
|
243
|
-
anns
|
|
244
|
+
if anns is None:
|
|
245
|
+
anns = resource.fetch_annotations(annotation_type='segmentation')
|
|
244
246
|
masks, names = _load_masks(anns, depth=vol.shape[0])
|
|
245
247
|
if masks is None:
|
|
246
248
|
_LOGGER.warning(f'No segmentations found for resource {resource.filename!r}')
|
|
@@ -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.
|
|
4
|
+
version = "2.53.1"
|
|
5
5
|
dynamic = ["dependencies"]
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/lightning_modules/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/deeplabv3plus.py
RENAMED
|
File without changes
|
{datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/efficientnetv2.py
RENAMED
|
File without changes
|
{datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/data_export.py
RENAMED
|
File without changes
|
{datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/data_import.py
RENAMED
|
File without changes
|
|
File without changes
|
{datamint-2.52.0 → datamint-2.53.1}/datamint/lightning/trainers/specialized/nnunet/trainer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|