kaiko-eva 0.0.0.dev6__py3-none-any.whl → 0.0.0.dev8__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.

Potentially problematic release.


This version of kaiko-eva might be problematic. Click here for more details.

@@ -19,7 +19,7 @@ def call_method_if_exists(objects: Iterable[Any], /, method: str) -> None:
19
19
 
20
20
 
21
21
  def _recursive_iter(objects: Iterable[Any], /) -> Iterable[datasets_lib.TorchDataset]:
22
- """Iterates thought an iterable of objects and their respective iterable values.
22
+ """Iterates through an iterable of objects and their respective iterable values.
23
23
 
24
24
  Args:
25
25
  objects: The objects to iterate from.
@@ -11,8 +11,9 @@ from loguru import logger
11
11
  def generate_session_id() -> str:
12
12
  """Generates and returns a unique string ID of an experiment.
13
13
 
14
- The ID is composed of the run timestamp and a its config hash. If the
15
- configuration hash is an empty string, it will use only the timestamp.
14
+ The ID is composed of the run timestamp and a hash based on th used
15
+ config. If the configuration hash is an empty string, it will use
16
+ only the timestamp.
16
17
  """
17
18
  timestamp = _generate_timestamp_hash()
18
19
  config_hash = _generate_config_hash()
@@ -34,8 +35,8 @@ def _generate_config_hash(max_hash_len: int = 8) -> str:
34
35
  config_path = _fetch_config_path()
35
36
  if config_path is None:
36
37
  logger.warning(
37
- "No or multiple configuration file found from command line arguments. "
38
- "No configuration hash code will created for this experiment."
38
+ "No or multiple configuration files found from command line arguments. "
39
+ "No configuration hash code will be created for this experiment."
39
40
  )
40
41
  return ""
41
42
 
@@ -78,7 +78,7 @@ class Trainer(pl_trainer.Trainer):
78
78
  model: modules.ModelModule,
79
79
  datamodule: datamodules.DataModule,
80
80
  ) -> None:
81
- """Runs a evaluation session out-of-place.
81
+ """Runs an evaluation session out-of-place.
82
82
 
83
83
  It performs an evaluation run (fit and evaluate) the model
84
84
  `self._n_run` times. Note that the input `base_model` would
@@ -1,5 +1,7 @@
1
1
  """Dataset validation related functions."""
2
2
 
3
+ import os
4
+
3
5
  from typing_extensions import List, Tuple
4
6
 
5
7
  from eva.vision.data.datasets import vision
@@ -18,7 +20,7 @@ def check_dataset_integrity(
18
20
  """Verifies the datasets integrity.
19
21
 
20
22
  Raise:
21
- ValuesError: If the input dataset's values do not
23
+ ValueError: If the input dataset's values do not
22
24
  match the expected ones.
23
25
  """
24
26
  if len(dataset) != length:
@@ -42,3 +44,16 @@ def check_dataset_integrity(
42
44
  f"({(dataset_classes[0], dataset_classes[-1])}) does not match the expected "
43
45
  f"ones ({first_and_last_labels}). {_SUFFIX_ERROR_MESSAGE}"
44
46
  )
47
+
48
+
49
+ def check_dataset_exists(dataset_dir: str, download_available: bool) -> None:
50
+ """Verifies that the dataset folder exists.
51
+
52
+ Raise:
53
+ FileNotFoundError: If the dataset folder does not exist.
54
+ """
55
+ if not os.path.isdir(dataset_dir):
56
+ error_message = f"Dataset not found at '{dataset_dir}'."
57
+ if download_available:
58
+ error_message += " You can set `download=True` to download the dataset automatically."
59
+ raise FileNotFoundError(error_message)
@@ -96,24 +96,25 @@ class BACH(base.ImageClassification):
96
96
  return {"Benign": 0, "InSitu": 1, "Invasive": 2, "Normal": 3}
97
97
 
98
98
  @property
99
- def dataset_path(self) -> str:
99
+ def _dataset_path(self) -> str:
100
100
  """Returns the path of the image data of the dataset."""
101
101
  return os.path.join(self._root, "ICIAR2018_BACH_Challenge", "Photos")
102
102
 
103
103
  @override
104
104
  def filename(self, index: int) -> str:
105
105
  image_path, _ = self._samples[self._indices[index]]
106
- return os.path.relpath(image_path, self.dataset_path)
106
+ return os.path.relpath(image_path, self._dataset_path)
107
107
 
108
108
  @override
109
109
  def prepare_data(self) -> None:
110
110
  if self._download:
111
111
  self._download_dataset()
112
+ _validators.check_dataset_exists(self._root, True)
112
113
 
113
114
  @override
114
115
  def configure(self) -> None:
115
116
  self._samples = folder.make_dataset(
116
- directory=self.dataset_path,
117
+ directory=self._dataset_path,
117
118
  class_to_idx=self.class_to_idx,
118
119
  extensions=(".tif"),
119
120
  )
@@ -145,7 +146,7 @@ class BACH(base.ImageClassification):
145
146
  def _download_dataset(self) -> None:
146
147
  """Downloads the dataset."""
147
148
  for resource in self._resources:
148
- if os.path.isdir(self.dataset_path):
149
+ if os.path.isdir(self._dataset_path):
149
150
  continue
150
151
 
151
152
  self._print_license()
@@ -95,12 +95,13 @@ class CRC(base.ImageClassification):
95
95
  @override
96
96
  def filename(self, index: int) -> str:
97
97
  image_path, *_ = self._samples[index]
98
- return os.path.relpath(image_path, self._dataset_dir)
98
+ return os.path.relpath(image_path, self._dataset_path)
99
99
 
100
100
  @override
101
101
  def prepare_data(self) -> None:
102
102
  if self._download:
103
103
  self._download_dataset()
104
+ _validators.check_dataset_exists(self._root, True)
104
105
 
105
106
  @override
106
107
  def configure(self) -> None:
@@ -135,7 +136,7 @@ class CRC(base.ImageClassification):
135
136
  return len(self._samples)
136
137
 
137
138
  @property
138
- def _dataset_dir(self) -> str:
139
+ def _dataset_path(self) -> str:
139
140
  """Returns the full path of dataset directory."""
140
141
  dataset_dirs = {
141
142
  "train": os.path.join(self._root, "NCT-CRC-HE-100K"),
@@ -150,7 +151,7 @@ class CRC(base.ImageClassification):
150
151
  def _make_dataset(self) -> List[Tuple[str, int]]:
151
152
  """Builds the dataset for the specified split."""
152
153
  dataset = folder.make_dataset(
153
- directory=self._dataset_dir,
154
+ directory=self._dataset_path,
154
155
  class_to_idx=self.class_to_idx,
155
156
  extensions=(".tif"),
156
157
  )
@@ -56,6 +56,10 @@ class MHIST(base.ImageClassification):
56
56
  image_filename, _ = self._samples[index]
57
57
  return image_filename
58
58
 
59
+ @override
60
+ def prepare_data(self) -> None:
61
+ _validators.check_dataset_exists(self._root, False)
62
+
59
63
  @override
60
64
  def configure(self) -> None:
61
65
  self._samples = self._make_dataset()
@@ -114,6 +114,7 @@ class PatchCamelyon(base.ImageClassification):
114
114
  def prepare_data(self) -> None:
115
115
  if self._download:
116
116
  self._download_dataset()
117
+ _validators.check_dataset_exists(self._root, True)
117
118
 
118
119
  @override
119
120
  def validate(self) -> None:
@@ -108,6 +108,7 @@ class TotalSegmentatorClassification(base.ImageClassification):
108
108
  def prepare_data(self) -> None:
109
109
  if self._download:
110
110
  self._download_dataset()
111
+ _validators.check_dataset_exists(self._root, True)
111
112
 
112
113
  @override
113
114
  def configure(self) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kaiko-eva
3
- Version: 0.0.0.dev6
3
+ Version: 0.0.0.dev8
4
4
  Summary: Evaluation Framework for oncology foundation models.
5
5
  Keywords: machine-learning evaluation-framework oncology foundation-models
6
6
  Author-Email: Ioannis Gatopoulos <ioannis@kaiko.ai>, Nicolas Känzig <nicolas@kaiko.ai>, Roman Moser <roman@kaiko.ai>
@@ -240,7 +240,7 @@ Description-Content-Type: text/markdown
240
240
 
241
241
  <div align="center">
242
242
 
243
- <img src="./docs/images/eva-logo.png" width="400">
243
+ <img src="https://github.com/kaiko-ai/eva/blob/main/docs/images/eva-logo.png?raw=true" width="400">
244
244
 
245
245
  <br />
246
246
 
@@ -251,27 +251,21 @@ _Oncology FM Evaluation Framework by kaiko.ai_
251
251
  [![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg?labelColor=gray)](https://github.com/kaiko-ai/eva#license)
252
252
 
253
253
  <p align="center">
254
- <a href="#installation">Installation</a> •
255
- <a href="#how-to-use">How To Use</a> •
254
+ <a href="https://github.com/kaiko-ai/eva#installation">Installation</a> •
255
+ <a href="https://github.com/kaiko-ai/eva#how-to-use">How To Use</a> •
256
256
  <a href="https://kaiko-ai.github.io/eva/">Documentation</a> •
257
257
  <a href="https://kaiko-ai.github.io/eva/dev/datasets/">Datasets</a> •
258
- <a href="#benchmarks">Benchmarks</a> <br>
259
- <a href="#contributing">Contribute</a> •
260
- <a href="#acknowledgements">Acknowledgements</a>
258
+ <a href="https://github.com/kaiko-ai/eva#benchmarks">Benchmarks</a> <br>
259
+ <a href="https://github.com/kaiko-ai/eva#contributing">Contribute</a> •
260
+ <a href="https://github.com/kaiko-ai/eva#acknowledgements">Acknowledgements</a>
261
261
  </p>
262
262
 
263
263
  </div>
264
264
 
265
- ### Introduction
265
+ <br />
266
266
 
267
267
  _`eva`_ is an evaluation framework for oncology foundation models (FMs) by [kaiko.ai](https://kaiko.ai/). Check out the [documentation](https://kaiko-ai.github.io/eva/) for more information.
268
268
 
269
- <div align="center">
270
-
271
- <img src="./docs/images/eva-process.gif" width="800">
272
-
273
- </div>
274
-
275
269
  ### Highlights:
276
270
  - Easy and reliable benchmark of Oncology FMs
277
271
  - Automatic embedding inference and evaluation of a downstream task
@@ -294,7 +288,7 @@ pip install 'kaiko-eva[all]'
294
288
 
295
289
  To install the latest version of the `main` branch:
296
290
  ```sh
297
- pip install "kaiko-eva[vision] @ git+https://github.com/kaiko-ai/eva.git"
291
+ pip install "kaiko-eva[all] @ git+https://github.com/kaiko-ai/eva.git"
298
292
  ```
299
293
 
300
294
  You can verify that the installation was successful by executing:
@@ -339,8 +333,8 @@ In this section you will find model benchmarks which were generated with _eva_.
339
333
  |--------------------------------------------------|-------|-------|-------|----------|-----------|
340
334
  | ViT-S/16 _(random)_ <sup>[1]</sup> | 0.410 | 0.617 | 0.501 | 0.753 | 0.728 |
341
335
  | ViT-S/16 _(ImageNet)_ <sup>[1]</sup> | 0.695 | 0.935 | 0.831 | 0.864 | 0.849 |
342
- | ViT-B/8 _(ImageNet)_ <sup>[1]</sup> | 0.797 | 0.943 | 0.828 | 0.903 | 0.893 |
343
- | DINO<sub>(p=16)</sub> <sup>[2]</sup> | 0.710 | 0.935 | 0.814 | 0.870 | 0.856 |
336
+ | ViT-B/8 _(ImageNet)_ <sup>[1]</sup> | 0.710 | 0.939 | 0.814 | 0.870 | 0.856 |
337
+ | DINO<sub>(p=16)</sub> <sup>[2]</sup> | 0.801 | 0.934 | 0.768 | 0.889 | 0.895 |
344
338
  | Phikon <sup>[3]</sup> | 0.725 | 0.935 | 0.777 | 0.912 | 0.915 |
345
339
  | ViT-S/16 _(kaiko.ai)_ <sup>[4]</sup> | 0.797 | 0.943 | 0.828 | 0.903 | 0.893 |
346
340
  | ViT-S/8 _(kaiko.ai)_ <sup>[4]</sup> | 0.834 | 0.946 | 0.832 | 0.897 | 0.887 |
@@ -349,7 +343,7 @@ In this section you will find model benchmarks which were generated with _eva_.
349
343
  | ViT-L/14 _(kaiko.ai)_ <sup>[4]</sup> | 0.870 | 0.930 | 0.809 | 0.908 | 0.898 |
350
344
 
351
345
  _Table I: Linear probing evaluation of FMs on patch-level downstream datasets.<br> We report averaged balanced accuracy
352
- over 5 runs_, with an average standard deviation of ±0.003.
346
+ over 5 runs, with an average standard deviation of ±0.003._
353
347
 
354
348
  </div>
355
349
 
@@ -359,7 +353,7 @@ _References_:
359
353
  1. _"Emerging properties in self-supervised vision transformers”_
360
354
  2. _"Benchmarking self-supervised learning on diverse pathology datasets”_
361
355
  3. _"Scaling self-supervised learning for histopathology with masked image modeling”_
362
- 4. _"Towards training Large-Scale Medical Foundation Models: from TCGA to hospital-scale pathology FMs”_
356
+ 4. _"Towards Training Large-Scale Pathology Foundation Models: from TCGA to Hospital Scale”_
363
357
 
364
358
  ## Contributing
365
359
 
@@ -389,5 +383,5 @@ Our codebase is built using multiple opensource contributions
389
383
 
390
384
  ---
391
385
  <div align="center">
392
- <img src="./docs/images/kaiko-logo.png" width="200">
386
+ <img src="https://github.com/kaiko-ai/eva/blob/main/docs/images/kaiko-logo.png?raw=true" width="200">
393
387
  </div>
@@ -15,7 +15,7 @@ eva/core/data/__init__.py,sha256=yG3BeOWhp1EjVYMFqx8M_TBWFDyfIwwksQGQmMdSPaI,340
15
15
  eva/core/data/dataloaders/__init__.py,sha256=fbNClVZ8J3QoGi4qiPq635ig1j9GdI7six3RhfwDbjY,110
16
16
  eva/core/data/dataloaders/dataloader.py,sha256=-mWFFLtem1Ijbi8XGveFSv5XzUU7SyKwiT5Ahikzghw,2368
17
17
  eva/core/data/datamodules/__init__.py,sha256=qZchYbgxo9lxYnGoqdk0C6MfS2IbF0WItO0kCdP9Mqc,229
18
- eva/core/data/datamodules/call.py,sha256=BYihrDdpAhMdRLhr1tA4I-veVe12bX3PNixGokbENQU,940
18
+ eva/core/data/datamodules/call.py,sha256=jjj9w3UXYuQB-qyCcw1EZpRJW10OC1I3dvgvsuQWLck,940
19
19
  eva/core/data/datamodules/datamodule.py,sha256=dclC2YJAXUGEUpV9ZRWQS43-ksFIPgVeFudsyrj9kdc,3878
20
20
  eva/core/data/datamodules/schemas.py,sha256=EXnUPNd9Pj3RjnxJIzAcC2qp6TtBSvPDx28fV_ovWAA,1869
21
21
  eva/core/data/datasets/__init__.py,sha256=pMU-w6aQoRFgSwPB9GLXNilnsbwd6HqLlgw49e4rlj0,281
@@ -63,11 +63,11 @@ eva/core/models/networks/wrappers/from_function.py,sha256=fuh-UEe3eppTwuSA2gEgCm
63
63
  eva/core/models/networks/wrappers/huggingface.py,sha256=81j0pcEx3DW6gR-81Fz6tZkJPBZYiQ-g45igFvkqX1o,1289
64
64
  eva/core/models/networks/wrappers/onnx.py,sha256=LZEGOpg1VYrB3wXMAA5IMfiKNTkOXQ50agHjTvYnnsU,1718
65
65
  eva/core/trainers/__init__.py,sha256=jhsKJF7HAae7EOiG3gKIAHH_h3dZlTE2JRcCHJmOzJc,208
66
- eva/core/trainers/_logging.py,sha256=AsYw-6NigCqPWEFCYOpbgFe5-5WxcdqMNiVuDvpqsgk,2550
66
+ eva/core/trainers/_logging.py,sha256=gi4FqPy2GuVmh0WZY6mYwF7zMPvnoFA050B0XdCP6PU,2571
67
67
  eva/core/trainers/_recorder.py,sha256=_Vfp7Njh_9qP-SWbBGYp8solnfFgIUi2Z9pGLXt52WY,5652
68
68
  eva/core/trainers/_utils.py,sha256=M3h8lVhUmkeSiEXpX9hRdMvThGFCnTP15gv-hd1CZkc,321
69
69
  eva/core/trainers/functional.py,sha256=pIeGXoO63Wh6n1mOYlBo5ACCteGuNV9pZhqxfN4RLSs,3775
70
- eva/core/trainers/trainer.py,sha256=8TVQb4HXZbvp5SXK1UnU2RIX9OcUbx6cbStRD5V3o3c,3260
70
+ eva/core/trainers/trainer.py,sha256=j4rYWiG9COxBbZ6WIlpRPBE153XqlYK7eAWlRsZgljU,3261
71
71
  eva/core/utils/__init__.py,sha256=F1C69M9y7W8qh1J2k-X4frRHa7r1mPXewscC94fFYtk,58
72
72
  eva/core/utils/io/__init__.py,sha256=SAME0kuSvDE1DKFJwMBmnCkpDAy4ujXuRTSJsHNhwUI,112
73
73
  eva/core/utils/io/dataframe.py,sha256=CIHFowljH17waDkJ9YJVEVXAIcxMwoLjUgoBttiNk8w,509
@@ -77,14 +77,14 @@ eva/vision/__init__.py,sha256=Pp9FZomuqfbZdKSOmgSGfNYk8ISpXf7tLVBZfoFcybk,432
77
77
  eva/vision/data/__init__.py,sha256=aoKPmX8P2Q2k2W3nlq8vFU41FV6Sze-0SDuWtU-ETh4,111
78
78
  eva/vision/data/datasets/__init__.py,sha256=aV4qPqtlt0PnaGoxUW_xEwAr8b8ddkl_YE4_fAdavds,497
79
79
  eva/vision/data/datasets/_utils.py,sha256=5GAZEHn-VezxTXaW1jVZO5zvdVl1Vz8_5gV2qkoMu4s,1414
80
- eva/vision/data/datasets/_validators.py,sha256=SewZrhs1bVXqDmdUBYOfyXNgjvGZ50-5pzdbzkelWmg,1595
80
+ eva/vision/data/datasets/_validators.py,sha256=uPbbUNnftb8mYzsKVrF-ZX_xinB2zQkuQLFYMprVjhY,2099
81
81
  eva/vision/data/datasets/classification/__init__.py,sha256=I9vTkETzGnTNNvyRB96ut1YHx9ARmZVO0-0l3ZLWEAs,520
82
- eva/vision/data/datasets/classification/bach.py,sha256=jJDQSJ4SJ2W-GxbUAvuYkiPTef-g5kdtYez2ewM89KM,5574
82
+ eva/vision/data/datasets/classification/bach.py,sha256=_xuA4evV9jCI76bUKbzom4ECLKShCsd95S8PtvhRAH4,5637
83
83
  eva/vision/data/datasets/classification/base.py,sha256=zBqn8rQP59j1DEChf3rDXgyMtB_sbug8kPvgFCqZyl4,3060
84
- eva/vision/data/datasets/classification/crc.py,sha256=ZTSrClCWh-jE4Rpmy_uXaUbQ4zjt4vPkqYTflX6m2SQ,5813
85
- eva/vision/data/datasets/classification/mhist.py,sha256=kqZivJNje_wZaHt_i6uCXMU486FbArvs0_crX0ryiao,3146
86
- eva/vision/data/datasets/classification/patch_camelyon.py,sha256=28Lg7umKM3S1TKNCfbpOuQyLlLVZ92BnjMmQNEnSH8I,7194
87
- eva/vision/data/datasets/classification/total_segmentator.py,sha256=JcRHATXpkB0uMr3XzMp9uTBG-_cQNgPhbkXqGBUMuOE,8010
84
+ eva/vision/data/datasets/classification/crc.py,sha256=7RR0PJWnhLMa3AUB_F2XMYawF5gnCNbGMv25ejOEeNA,5875
85
+ eva/vision/data/datasets/classification/mhist.py,sha256=yoDHZ2vqa26YKVvJ9t6aidOVGazGIwUD6F3o0zNsxjM,3257
86
+ eva/vision/data/datasets/classification/patch_camelyon.py,sha256=CH9sveoMppNWPQHm4qPTONRSGqX3O8P3OYwMB6mO678,7253
87
+ eva/vision/data/datasets/classification/total_segmentator.py,sha256=OkbqS41ykdUX0wGf6jSja5WzeeRmevUnH5alfcEQhwg,8069
88
88
  eva/vision/data/datasets/segmentation/__init__.py,sha256=byQCBHicM6mQkljHPllUqRvoFaJxHtPMKcyjPmK6dUM,249
89
89
  eva/vision/data/datasets/segmentation/base.py,sha256=JogXJ3KiOaUybAcyvoqjR4yjlBfVTt2Rt8OOAz32Jrc,3630
90
90
  eva/vision/data/datasets/segmentation/total_segmentator.py,sha256=NUh-NlrsTcUsbe3qLd_d481mok970bNF7zIdpAS7eks,8075
@@ -104,8 +104,8 @@ eva/vision/utils/io/_utils.py,sha256=JzOt7Frj6ScF_aNjFtfHBn4ROnl6NhUZucmQhLc4Cww
104
104
  eva/vision/utils/io/image.py,sha256=2jzeVFMvIRhuTkIrQeLyu0y8GttLp6rWRjO9I2uw-I8,1489
105
105
  eva/vision/utils/io/nifti.py,sha256=ph9w8dNNSsJG2wI3NJNPTLyWdz2S0i9jD068nHXVVJs,1510
106
106
  eva/vision/utils/io/text.py,sha256=uECChKjeKi4KQ-NqdO7ywAFS_TOEp2DQ5QQcuG8cb-4,472
107
- kaiko_eva-0.0.0.dev6.dist-info/METADATA,sha256=653ZvK1f_JAdJqvhuItMUhdPj_207iutLC6-OGooT2I,21424
108
- kaiko_eva-0.0.0.dev6.dist-info/WHEEL,sha256=N2J68yzZqJh3mI_Wg92rwhw0rtJDFpZj9bwQIMJgaVg,90
109
- kaiko_eva-0.0.0.dev6.dist-info/entry_points.txt,sha256=oqtS2Yt5EBY4saLyCBC3Zev3huCORKTKWyPovX7QR8g,73
110
- kaiko_eva-0.0.0.dev6.dist-info/licenses/LICENSE,sha256=e6AEzr7j_R-PYr2qLO-JwLn8y70jbVD3U2mxbRmwcI4,11338
111
- kaiko_eva-0.0.0.dev6.dist-info/RECORD,,
107
+ kaiko_eva-0.0.0.dev8.dist-info/METADATA,sha256=M4MrBZhhW_RFJcR3J8kjSgRN7lauwINudUoEO1y6AO8,21567
108
+ kaiko_eva-0.0.0.dev8.dist-info/WHEEL,sha256=N2J68yzZqJh3mI_Wg92rwhw0rtJDFpZj9bwQIMJgaVg,90
109
+ kaiko_eva-0.0.0.dev8.dist-info/entry_points.txt,sha256=oqtS2Yt5EBY4saLyCBC3Zev3huCORKTKWyPovX7QR8g,73
110
+ kaiko_eva-0.0.0.dev8.dist-info/licenses/LICENSE,sha256=e6AEzr7j_R-PYr2qLO-JwLn8y70jbVD3U2mxbRmwcI4,11338
111
+ kaiko_eva-0.0.0.dev8.dist-info/RECORD,,