quadra 2.2.1__py3-none-any.whl → 2.2.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
quadra/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "2.2.1"
1
+ __version__ = "2.2.3"
2
2
 
3
3
 
4
4
  def get_version():
quadra/main.py CHANGED
@@ -1,6 +1,7 @@
1
1
  import time
2
2
 
3
3
  import hydra
4
+ import matplotlib
4
5
  from omegaconf import DictConfig
5
6
  from pytorch_lightning import seed_everything
6
7
 
@@ -12,6 +13,8 @@ from quadra.utils.validator import validate_config
12
13
  load_envs()
13
14
  register_resolvers()
14
15
 
16
+
17
+ matplotlib.use("Agg")
15
18
  log = get_logger(__name__)
16
19
 
17
20
 
@@ -138,13 +138,9 @@ class ClassificationModule(BaseLightningModule):
138
138
  if isinstance(self.model.features_extractor, timm.models.resnet.ResNet):
139
139
  target_layers = [cast(BaseNetworkBuilder, self.model).features_extractor.layer4[-1]]
140
140
 
141
- # Get model current device
142
- device = next(self.model.parameters()).device
143
-
144
141
  self.cam = GradCAM(
145
142
  model=self.model,
146
143
  target_layers=target_layers,
147
- use_cuda=device.type == "cuda",
148
144
  )
149
145
  # Activating gradients
150
146
  for p in self.model.features_extractor.layer4[-1].parameters():
@@ -262,7 +258,7 @@ class MultilabelClassificationModule(BaseLightningModule):
262
258
  self.gradcam = False
263
259
  else:
264
260
  target_layers = [model[0].features_extractor.layer4[-1]]
265
- self.cam = GradCAM(model=model, target_layers=target_layers, use_cuda=torch.cuda.is_available())
261
+ self.cam = GradCAM(model=model, target_layers=target_layers)
266
262
 
267
263
  def forward(self, x):
268
264
  return self.model(x)
@@ -1138,7 +1138,6 @@ class ClassificationEvaluation(Evaluation[ClassificationDataModuleT]):
1138
1138
  self.cam = GradCAM(
1139
1139
  model=self.deployment_model.model,
1140
1140
  target_layers=target_layers,
1141
- use_cuda=(self.device != "cpu"),
1142
1141
  )
1143
1142
  for p in self.deployment_model.model.features_extractor.layer4[-1].parameters():
1144
1143
  p.requires_grad = True
quadra/utils/export.py CHANGED
@@ -7,7 +7,6 @@ from typing import Any, Literal, TypeVar, cast
7
7
  import torch
8
8
  from anomalib.models.cflow import CflowLightning
9
9
  from omegaconf import DictConfig, ListConfig, OmegaConf
10
- from onnxconverter_common import auto_convert_mixed_precision
11
10
  from torch import nn
12
11
 
13
12
  from quadra.models.base import ModelSignatureWrapper
@@ -22,6 +21,7 @@ from quadra.utils.logger import get_logger
22
21
  try:
23
22
  import onnx # noqa
24
23
  from onnxsim import simplify as onnx_simplify # noqa
24
+ from onnxconverter_common import auto_convert_mixed_precision # noqa
25
25
 
26
26
  ONNX_AVAILABLE = True
27
27
  except ImportError:
@@ -385,8 +385,9 @@ def _safe_export_half_precision_onnx(
385
385
  onnx.checker.check_model(onnx_model)
386
386
  return True
387
387
  except Exception as e:
388
- log.debug("Failed to export model with mixed precision with error: %s", e)
389
- return False
388
+ raise RuntimeError(
389
+ "Failed to export model with automatic mixed precision, check your model or disable ONNX export"
390
+ ) from e
390
391
  else:
391
392
  log.info("Exported half precision ONNX model does not contain NaN values, model is stable")
392
393
  return True
quadra/utils/models.py CHANGED
@@ -131,7 +131,6 @@ def get_feature(
131
131
  cam = GradCAM(
132
132
  model=feature_extractor,
133
133
  target_layers=target_layers,
134
- use_cuda=torch.cuda.is_available(),
135
134
  )
136
135
  for p in feature_extractor.features_extractor.layer4[-1].parameters():
137
136
  p.requires_grad = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quadra
3
- Version: 2.2.1
3
+ Version: 2.2.3
4
4
  Summary: Deep Learning experiment orchestration library
5
5
  Home-page: https://orobix.github.io/quadra
6
6
  License: Apache-2.0
@@ -21,9 +21,9 @@ Classifier: Topic :: Software Development :: Libraries
21
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
22
  Provides-Extra: onnx
23
23
  Requires-Dist: albumentations (>=1.3,<1.4)
24
- Requires-Dist: anomalib-orobix (==0.7.0.dev140)
24
+ Requires-Dist: anomalib-orobix (==0.7.0.dev141)
25
25
  Requires-Dist: boto3 (>=1.26,<1.27)
26
- Requires-Dist: grad_cam (==1.4.6)
26
+ Requires-Dist: grad-cam-orobix (==1.5.3.dev001)
27
27
  Requires-Dist: h5py (>=3.8,<3.9)
28
28
  Requires-Dist: hydra_colorlog (>=1.2,<1.3)
29
29
  Requires-Dist: hydra_core (>=1.3,<1.4)
@@ -235,7 +235,7 @@ On the same dataset we can run a simple SSL training using the BYOL algorithm wi
235
235
  quadra experiment=generic/imagenette/ssl/byol logger=csv
236
236
  ```
237
237
 
238
- BYOL is not the only SSL algorithm available, you can find a list of all the available algorithms under `quadra/experiment/generic/imagenette/ssl` folder.
238
+ BYOL is not the only SSL algorithm available, you can find a list of all the available algorithms under `quadra/configs/experiment/generic/imagenette/ssl` folder.
239
239
 
240
240
 
241
241
  ### Anomaly Detection Training
@@ -248,11 +248,11 @@ quadra experiment=generic/mnist/anomaly/padim logger=csv
248
248
 
249
249
  This will run an anomaly detection considering on of the classes as good (default is the number 9) and the rest as anomalies.
250
250
 
251
- This will make use of the [anomalib](https://github.com/openvinotoolkit/anomalib) library to train the model. Many different algorithms are available, you can find them under `quadra/experiment/generic/mnist/anomaly` folder.
251
+ This will make use of the [anomalib](https://github.com/openvinotoolkit/anomalib) library to train the model. Many different algorithms are available, you can find them under `quadra/configs/experiment/generic/mnist/anomaly` folder.
252
252
 
253
253
  ## Running with Custom Datasets
254
254
 
255
- Each task comes with a default configuration file that can be customized for your needs. Each example experiment we have seen so far uses a default configuration file that can be found under `quadra/experiment/base/<task>/<config_name>.yaml`.
255
+ Each task comes with a default configuration file that can be customized for your needs. Each example experiment we have seen so far uses a default configuration file that can be found under `quadra/configs/experiment/base/<task>/<config_name>.yaml`.
256
256
 
257
257
  Let's see how we can customize the configuration file to run the classification experiment on a custom dataset.
258
258
 
@@ -1,4 +1,4 @@
1
- quadra/__init__.py,sha256=bj3AEzHwe7kkbVQLXh02eIMYTIaEUW3lRpTDkYpFCwM,112
1
+ quadra/__init__.py,sha256=k4RvIQHL_Vg6uYb-uXD4XswG0lCw26LdATU9LN4dpu8,112
2
2
  quadra/callbacks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  quadra/callbacks/anomalib.py,sha256=Z0Xx3M9UEMYGY0BpSsqemgQSQ6jAr4SrvlbDg_oG9C8,11913
4
4
  quadra/callbacks/lightning.py,sha256=1OTM6fB7qBVLPWNBAZJOb3B00q0kAxMWkPjTEn9YgF0,20182
@@ -217,7 +217,7 @@ quadra/losses/ssl/idmm.py,sha256=DyECUEBq7eefda4yuza0KQShztaEJaLIYdEgMOKwpXM,114
217
217
  quadra/losses/ssl/simclr.py,sha256=Di8hKeQEnIAyYhEHrm3H-6cw_JQ7-0vqc7dKz8uxBlI,2209
218
218
  quadra/losses/ssl/simsiam.py,sha256=uCCbqU9aYMwNa3re0qkeEK5Iz7Hxi0jAcEc-sCWZ8fc,877
219
219
  quadra/losses/ssl/vicreg.py,sha256=ANvhYJz6iPv1A-OBXgBSrZrDG-1VmPtK1IZDtyFqNHE,2427
220
- quadra/main.py,sha256=xh8n-Sb_D0w_4L6RaGA39-ie3odz6OGHpOu0pEIwR8g,1366
220
+ quadra/main.py,sha256=6ZYKytVvCzQjgP_0QA6-3ICzVppsbRgPjF-csLKv85o,1407
221
221
  quadra/metrics/__init__.py,sha256=HsTK1gxsjp8_MYgA5caa4OK8sXLqtK_tt9wYyjtFnOc,79
222
222
  quadra/metrics/segmentation.py,sha256=jkQzCUz0ibkEoF95-uL-4wwxybs5SAs2VHiT5ZGckso,9451
223
223
  quadra/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -230,7 +230,7 @@ quadra/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
230
230
  quadra/modules/backbone.py,sha256=xiZBqgzr1S45GX9mydl29TFuahLDaHrU7Fy73LGIyGI,909
231
231
  quadra/modules/base.py,sha256=fS_kbOAfEihHFfiTcyuyDXTzkmkJr2ivtAMiZqjOUog,10303
232
232
  quadra/modules/classification/__init__.py,sha256=6keltBhC1yzgbNttBuykNYJAUMyOrY-HDNgGZGfI93I,141
233
- quadra/modules/classification/base.py,sha256=kC2vPHMEoeHyK_tECau9W9ynLMJzkI9cpOjs-DZeU1k,12119
233
+ quadra/modules/classification/base.py,sha256=QdHtHY2tF_qh2wU01Oo0TWjh9CTqa46tyF4VgcLd__M,11937
234
234
  quadra/modules/ssl/__init__.py,sha256=oeUoGHrsESZ0595-JxPxURBP124jtNfrITbVovBpANA,302
235
235
  quadra/modules/ssl/barlowtwins.py,sha256=iW6f7ADSEkbs7z-88x680204-Ez-iF1Yd2SdQzcLpRY,1884
236
236
  quadra/modules/ssl/byol.py,sha256=8sviU7MS9MXDbS9Ogu9-qJCZrkTI2pPxgEwNvc7EqIo,7084
@@ -250,7 +250,7 @@ quadra/schedulers/warmup.py,sha256=chzzrK7OqqlicBCxiF4CqMYNrWu6nflIbRE-C86Jrw0,4
250
250
  quadra/tasks/__init__.py,sha256=tmAfMoH0k3UC7r2pNrgbBa1Pfc3tpLl3IObFF6Z0eRE,820
251
251
  quadra/tasks/anomaly.py,sha256=rl3F39kABt5deSLOeY2s_1t2mR4x1-42VdP0flRrZMs,24583
252
252
  quadra/tasks/base.py,sha256=5Rsjdothqb4YXMIN_s98HdoPmJBfQKV0ZwnyvUuihYI,14101
253
- quadra/tasks/classification.py,sha256=w3bq_EPgz3X---iaGBlVD9hb3ncWPClbrjm6496Heh8,52784
253
+ quadra/tasks/classification.py,sha256=I4NEsNVn1lOu-HLaD_hqowfnedhD4l-wZ4JPI1eD4pg,52735
254
254
  quadra/tasks/patch.py,sha256=EJvbtvlebyOtk6m47juW8XMXr1v_bLFTIKqI1KC0HRA,20244
255
255
  quadra/tasks/segmentation.py,sha256=5GF7CZjm1dQGQ-Q0kAc68GSsNv6FTxBsl_rbEZQwjmU,16213
256
256
  quadra/tasks/ssl.py,sha256=SVZeAW5xVkfeGTwMqRhGKLagMC2kHrxoOaNEDzbCZ0A,20552
@@ -262,12 +262,12 @@ quadra/utils/anomaly.py,sha256=49vFvT5-4SxczsEM2Akcut_M1DDwKlOVdGv36oLTgR0,4067
262
262
  quadra/utils/classification.py,sha256=7Phbywpd1CNzwLM5F7zV9FrzdHGd6EkR6LRTRpkerTc,24882
263
263
  quadra/utils/deprecation.py,sha256=zF_S-yqenaZxRBOudhXts0mX763WjEUWCnHd09TZnwY,852
264
264
  quadra/utils/evaluation.py,sha256=5Occ6ONsjnvMkaFFjohtgSvffxEKfjdvMbxqzgtmiHQ,18538
265
- quadra/utils/export.py,sha256=Dsl470bE7vFDfNJbWeSDFc_LY8VVEY4pFL1rGQFP0hU,20542
265
+ quadra/utils/export.py,sha256=ddTslYMjdm6tYMPZPp-NpLAjUN6jwsgEItTZv2NBx0c,20608
266
266
  quadra/utils/imaging.py,sha256=Cz7sGb_axEmnGcwQJP2djFZpIpGCPFIBGT8NWVV-OOE,866
267
267
  quadra/utils/logger.py,sha256=tQJ4xpTAFKx1g-UUm5K1x7zgoP6qoXpcUHQyu0rOr1w,556
268
268
  quadra/utils/mlflow.py,sha256=7E09JShGm2qO7bLb_8srA_RYdVAudxeDYmX7pMdjoVU,3524
269
269
  quadra/utils/model_manager.py,sha256=P5JtY95p6giQ6mb4TUnWsNwUh5ClzHBillnG5SA56QY,12546
270
- quadra/utils/models.py,sha256=lJRnZQuxW8KRPdokIl3snBQX4e6IA2Yqil8-ZsIkXlA,19808
270
+ quadra/utils/models.py,sha256=xLOT6Sorpc54dYn9XG8RpqoLupvNrMCiE_QvvIMLwHA,19756
271
271
  quadra/utils/patch/__init__.py,sha256=YenDdsI937kyAJiE0dP3_Xua8gHIoFjheoWMnpx_TGU,509
272
272
  quadra/utils/patch/dataset.py,sha256=hqM7XyPNDmI9_uJSrAxNYOasdNlEHcg-npP1S9Bb05Y,61374
273
273
  quadra/utils/patch/metrics.py,sha256=E1PeHFp10pPgkb6484fDvRLn2E9NDy9xIqEmMBeusOw,17644
@@ -293,8 +293,8 @@ quadra/utils/validator.py,sha256=eFCGr0ss1gYSpsL31JbsCXPZUMJAI9_H-mGodt6UGsU,466
293
293
  quadra/utils/visualization.py,sha256=UvGHX0dumfjpT_KX3Yc1W2B5sAXXaZZWIwXQAi4sdoQ,15950
294
294
  quadra/utils/vit_explainability.py,sha256=hY0awehj6UkyBhnBlW5uWoJTsBfgow5Nll9fAqrzmMo,13337
295
295
  hydra_plugins/quadra_searchpath_plugin.py,sha256=AAn4TzR87zUK7nwSsK-KoqALiPtfQ8FvX3fgZPTGIJ0,1189
296
- quadra-2.2.1.dist-info/LICENSE,sha256=8cTbQtcWa02YJoSpMeV_gxj3jpMTkxvl-w3WJ5gV_QE,11342
297
- quadra-2.2.1.dist-info/METADATA,sha256=2Y7BAF6SzOVp7kIeF1TEgbJy-8JV-fMJb1S-juZ0ddQ,17585
298
- quadra-2.2.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
299
- quadra-2.2.1.dist-info/entry_points.txt,sha256=sRYonBZyx-sAJeWcQNQoVQIU5lm02cnCQt6b15k0WHU,43
300
- quadra-2.2.1.dist-info/RECORD,,
296
+ quadra-2.2.3.dist-info/LICENSE,sha256=8cTbQtcWa02YJoSpMeV_gxj3jpMTkxvl-w3WJ5gV_QE,11342
297
+ quadra-2.2.3.dist-info/METADATA,sha256=cRx79iZ9AKEE8bWu8gvMy_NSdp5KuM2IrZB_eGdQU5E,17623
298
+ quadra-2.2.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
299
+ quadra-2.2.3.dist-info/entry_points.txt,sha256=sRYonBZyx-sAJeWcQNQoVQIU5lm02cnCQt6b15k0WHU,43
300
+ quadra-2.2.3.dist-info/RECORD,,
File without changes