quadra 0.0.1__tar.gz → 2.2.7__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 (303) hide show
  1. quadra-2.2.7/LICENSE +201 -0
  2. quadra-2.2.7/PKG-INFO +381 -0
  3. quadra-2.2.7/README.md +317 -0
  4. quadra-2.2.7/pyproject.toml +295 -0
  5. quadra-2.2.7/quadra/__init__.py +6 -0
  6. quadra-2.2.7/quadra/callbacks/anomalib.py +289 -0
  7. quadra-2.2.7/quadra/callbacks/lightning.py +501 -0
  8. quadra-2.2.7/quadra/callbacks/mlflow.py +291 -0
  9. quadra-2.2.7/quadra/callbacks/scheduler.py +69 -0
  10. quadra-2.2.7/quadra/configs/__init__.py +0 -0
  11. quadra-2.2.7/quadra/configs/backbone/caformer_m36.yaml +8 -0
  12. quadra-2.2.7/quadra/configs/backbone/caformer_s36.yaml +8 -0
  13. quadra-2.2.7/quadra/configs/backbone/convnextv2_base.yaml +8 -0
  14. quadra-2.2.7/quadra/configs/backbone/convnextv2_femto.yaml +8 -0
  15. quadra-2.2.7/quadra/configs/backbone/convnextv2_tiny.yaml +8 -0
  16. quadra-2.2.7/quadra/configs/backbone/dino_vitb8.yaml +12 -0
  17. quadra-2.2.7/quadra/configs/backbone/dino_vits8.yaml +12 -0
  18. quadra-2.2.7/quadra/configs/backbone/dinov2_vitb14.yaml +12 -0
  19. quadra-2.2.7/quadra/configs/backbone/dinov2_vits14.yaml +12 -0
  20. quadra-2.2.7/quadra/configs/backbone/efficientnet_b0.yaml +8 -0
  21. quadra-2.2.7/quadra/configs/backbone/efficientnet_b1.yaml +8 -0
  22. quadra-2.2.7/quadra/configs/backbone/efficientnet_b2.yaml +8 -0
  23. quadra-2.2.7/quadra/configs/backbone/efficientnet_b3.yaml +8 -0
  24. quadra-2.2.7/quadra/configs/backbone/efficientnetv2_s.yaml +8 -0
  25. quadra-2.2.7/quadra/configs/backbone/levit_128s.yaml +8 -0
  26. quadra-2.2.7/quadra/configs/backbone/mnasnet0_5.yaml +9 -0
  27. quadra-2.2.7/quadra/configs/backbone/resnet101.yaml +8 -0
  28. quadra-2.2.7/quadra/configs/backbone/resnet18.yaml +8 -0
  29. quadra-2.2.7/quadra/configs/backbone/resnet18_ssl.yaml +8 -0
  30. quadra-2.2.7/quadra/configs/backbone/resnet50.yaml +8 -0
  31. quadra-2.2.7/quadra/configs/backbone/smp.yaml +9 -0
  32. quadra-2.2.7/quadra/configs/backbone/tiny_vit_21m_224.yaml +9 -0
  33. quadra-2.2.7/quadra/configs/backbone/unetr.yaml +15 -0
  34. quadra-2.2.7/quadra/configs/backbone/vit16_base.yaml +9 -0
  35. quadra-2.2.7/quadra/configs/backbone/vit16_small.yaml +9 -0
  36. quadra-2.2.7/quadra/configs/backbone/vit16_tiny.yaml +9 -0
  37. quadra-2.2.7/quadra/configs/backbone/xcit_tiny_24_p8_224.yaml +9 -0
  38. quadra-2.2.7/quadra/configs/callbacks/all.yaml +45 -0
  39. quadra-2.2.7/quadra/configs/callbacks/default.yaml +34 -0
  40. quadra-2.2.7/quadra/configs/callbacks/default_anomalib.yaml +64 -0
  41. quadra-2.2.7/quadra/configs/config.yaml +33 -0
  42. quadra-2.2.7/quadra/configs/core/default.yaml +11 -0
  43. quadra-2.2.7/quadra/configs/datamodule/base/anomaly.yaml +16 -0
  44. quadra-2.2.7/quadra/configs/datamodule/base/classification.yaml +21 -0
  45. quadra-2.2.7/quadra/configs/datamodule/base/multilabel_classification.yaml +23 -0
  46. quadra-2.2.7/quadra/configs/datamodule/base/segmentation.yaml +18 -0
  47. quadra-2.2.7/quadra/configs/datamodule/base/segmentation_multiclass.yaml +20 -0
  48. quadra-2.2.7/quadra/configs/datamodule/base/sklearn_classification.yaml +23 -0
  49. quadra-2.2.7/quadra/configs/datamodule/base/sklearn_classification_patch.yaml +17 -0
  50. quadra-2.2.7/quadra/configs/datamodule/base/ssl.yaml +21 -0
  51. quadra-2.2.7/quadra/configs/datamodule/generic/imagenette/classification/base.yaml +9 -0
  52. quadra-2.2.7/quadra/configs/datamodule/generic/imagenette/ssl/base.yaml +10 -0
  53. quadra-2.2.7/quadra/configs/datamodule/generic/mnist/anomaly/base.yaml +14 -0
  54. quadra-2.2.7/quadra/configs/datamodule/generic/mvtec/anomaly/base.yaml +14 -0
  55. quadra-2.2.7/quadra/configs/datamodule/generic/oxford_pet/segmentation/base.yaml +9 -0
  56. quadra-2.2.7/quadra/configs/experiment/base/anomaly/cfa.yaml +47 -0
  57. quadra-2.2.7/quadra/configs/experiment/base/anomaly/cflow.yaml +47 -0
  58. quadra-2.2.7/quadra/configs/experiment/base/anomaly/csflow.yaml +48 -0
  59. quadra-2.2.7/quadra/configs/experiment/base/anomaly/draem.yaml +51 -0
  60. quadra-2.2.7/quadra/configs/experiment/base/anomaly/efficient_ad.yaml +43 -0
  61. quadra-2.2.7/quadra/configs/experiment/base/anomaly/fastflow.yaml +46 -0
  62. quadra-2.2.7/quadra/configs/experiment/base/anomaly/inference.yaml +21 -0
  63. quadra-2.2.7/quadra/configs/experiment/base/anomaly/padim.yaml +37 -0
  64. quadra-2.2.7/quadra/configs/experiment/base/anomaly/patchcore.yaml +37 -0
  65. quadra-2.2.7/quadra/configs/experiment/base/classification/classification.yaml +73 -0
  66. quadra-2.2.7/quadra/configs/experiment/base/classification/classification_evaluation.yaml +25 -0
  67. quadra-2.2.7/quadra/configs/experiment/base/classification/multilabel_classification.yaml +41 -0
  68. quadra-2.2.7/quadra/configs/experiment/base/classification/sklearn_classification.yaml +27 -0
  69. quadra-2.2.7/quadra/configs/experiment/base/classification/sklearn_classification_patch.yaml +25 -0
  70. quadra-2.2.7/quadra/configs/experiment/base/classification/sklearn_classification_patch_test.yaml +18 -0
  71. quadra-2.2.7/quadra/configs/experiment/base/classification/sklearn_classification_test.yaml +25 -0
  72. quadra-2.2.7/quadra/configs/experiment/base/segmentation/smp.yaml +30 -0
  73. quadra-2.2.7/quadra/configs/experiment/base/segmentation/smp_evaluation.yaml +17 -0
  74. quadra-2.2.7/quadra/configs/experiment/base/segmentation/smp_multiclass.yaml +26 -0
  75. quadra-2.2.7/quadra/configs/experiment/base/segmentation/smp_multiclass_evaluation.yaml +18 -0
  76. quadra-2.2.7/quadra/configs/experiment/base/ssl/barlow.yaml +48 -0
  77. quadra-2.2.7/quadra/configs/experiment/base/ssl/byol.yaml +43 -0
  78. quadra-2.2.7/quadra/configs/experiment/base/ssl/dino.yaml +46 -0
  79. quadra-2.2.7/quadra/configs/experiment/base/ssl/linear_eval.yaml +52 -0
  80. quadra-2.2.7/quadra/configs/experiment/base/ssl/simclr.yaml +48 -0
  81. quadra-2.2.7/quadra/configs/experiment/base/ssl/simsiam.yaml +53 -0
  82. quadra-2.2.7/quadra/configs/experiment/custom/cls.yaml +12 -0
  83. quadra-2.2.7/quadra/configs/experiment/default.yaml +15 -0
  84. quadra-2.2.7/quadra/configs/experiment/generic/imagenette/classification/default.yaml +20 -0
  85. quadra-2.2.7/quadra/configs/experiment/generic/imagenette/ssl/barlow.yaml +14 -0
  86. quadra-2.2.7/quadra/configs/experiment/generic/imagenette/ssl/byol.yaml +14 -0
  87. quadra-2.2.7/quadra/configs/experiment/generic/imagenette/ssl/dino.yaml +14 -0
  88. quadra-2.2.7/quadra/configs/experiment/generic/imagenette/ssl/simclr.yaml +14 -0
  89. quadra-2.2.7/quadra/configs/experiment/generic/imagenette/ssl/simsiam.yaml +14 -0
  90. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/cfa.yaml +34 -0
  91. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/cflow.yaml +33 -0
  92. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/csflow.yaml +33 -0
  93. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/draem.yaml +33 -0
  94. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/fastflow.yaml +29 -0
  95. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/inference.yaml +27 -0
  96. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/padim.yaml +37 -0
  97. quadra-2.2.7/quadra/configs/experiment/generic/mnist/anomaly/patchcore.yaml +37 -0
  98. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/cfa.yaml +34 -0
  99. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/cflow.yaml +33 -0
  100. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/csflow.yaml +33 -0
  101. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/draem.yaml +33 -0
  102. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/efficient_ad.yaml +38 -0
  103. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/fastflow.yaml +29 -0
  104. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/inference.yaml +27 -0
  105. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/padim.yaml +37 -0
  106. quadra-2.2.7/quadra/configs/experiment/generic/mvtec/anomaly/patchcore.yaml +37 -0
  107. quadra-2.2.7/quadra/configs/experiment/generic/oxford_pet/segmentation/smp.yaml +27 -0
  108. quadra-2.2.7/quadra/configs/export/default.yaml +13 -0
  109. quadra-2.2.7/quadra/configs/hydra/anomaly_custom.yaml +15 -0
  110. quadra-2.2.7/quadra/configs/hydra/default.yaml +14 -0
  111. quadra-2.2.7/quadra/configs/inference/default.yaml +26 -0
  112. quadra-2.2.7/quadra/configs/logger/comet.yaml +10 -0
  113. quadra-2.2.7/quadra/configs/logger/csv.yaml +5 -0
  114. quadra-2.2.7/quadra/configs/logger/mlflow.yaml +12 -0
  115. quadra-2.2.7/quadra/configs/logger/tensorboard.yaml +8 -0
  116. quadra-2.2.7/quadra/configs/loss/asl.yaml +7 -0
  117. quadra-2.2.7/quadra/configs/loss/barlow.yaml +2 -0
  118. quadra-2.2.7/quadra/configs/loss/bce.yaml +1 -0
  119. quadra-2.2.7/quadra/configs/loss/byol.yaml +1 -0
  120. quadra-2.2.7/quadra/configs/loss/cross_entropy.yaml +1 -0
  121. quadra-2.2.7/quadra/configs/loss/dino.yaml +8 -0
  122. quadra-2.2.7/quadra/configs/loss/simclr.yaml +2 -0
  123. quadra-2.2.7/quadra/configs/loss/simsiam.yaml +1 -0
  124. quadra-2.2.7/quadra/configs/loss/smp_ce.yaml +3 -0
  125. quadra-2.2.7/quadra/configs/loss/smp_dice.yaml +2 -0
  126. quadra-2.2.7/quadra/configs/loss/smp_dice_multiclass.yaml +2 -0
  127. quadra-2.2.7/quadra/configs/loss/smp_mcc.yaml +2 -0
  128. quadra-2.2.7/quadra/configs/loss/vicreg.yaml +5 -0
  129. quadra-2.2.7/quadra/configs/model/anomalib/cfa.yaml +35 -0
  130. quadra-2.2.7/quadra/configs/model/anomalib/cflow.yaml +30 -0
  131. quadra-2.2.7/quadra/configs/model/anomalib/csflow.yaml +34 -0
  132. quadra-2.2.7/quadra/configs/model/anomalib/dfm.yaml +19 -0
  133. quadra-2.2.7/quadra/configs/model/anomalib/draem.yaml +29 -0
  134. quadra-2.2.7/quadra/configs/model/anomalib/efficient_ad.yaml +31 -0
  135. quadra-2.2.7/quadra/configs/model/anomalib/fastflow.yaml +32 -0
  136. quadra-2.2.7/quadra/configs/model/anomalib/padim.yaml +32 -0
  137. quadra-2.2.7/quadra/configs/model/anomalib/patchcore.yaml +36 -0
  138. quadra-2.2.7/quadra/configs/model/barlow.yaml +16 -0
  139. quadra-2.2.7/quadra/configs/model/byol.yaml +25 -0
  140. quadra-2.2.7/quadra/configs/model/classification.yaml +10 -0
  141. quadra-2.2.7/quadra/configs/model/dino.yaml +26 -0
  142. quadra-2.2.7/quadra/configs/model/logistic_regression.yaml +4 -0
  143. quadra-2.2.7/quadra/configs/model/multilabel_classification.yaml +9 -0
  144. quadra-2.2.7/quadra/configs/model/simclr.yaml +18 -0
  145. quadra-2.2.7/quadra/configs/model/simsiam.yaml +24 -0
  146. quadra-2.2.7/quadra/configs/model/smp.yaml +4 -0
  147. quadra-2.2.7/quadra/configs/model/smp_multiclass.yaml +4 -0
  148. quadra-2.2.7/quadra/configs/model/vicreg.yaml +16 -0
  149. quadra-2.2.7/quadra/configs/optimizer/adam.yaml +5 -0
  150. quadra-2.2.7/quadra/configs/optimizer/adamw.yaml +3 -0
  151. quadra-2.2.7/quadra/configs/optimizer/default.yaml +4 -0
  152. quadra-2.2.7/quadra/configs/optimizer/lars.yaml +8 -0
  153. quadra-2.2.7/quadra/configs/optimizer/sgd.yaml +4 -0
  154. quadra-2.2.7/quadra/configs/scheduler/default.yaml +5 -0
  155. quadra-2.2.7/quadra/configs/scheduler/rop.yaml +5 -0
  156. quadra-2.2.7/quadra/configs/scheduler/step.yaml +3 -0
  157. quadra-2.2.7/quadra/configs/scheduler/warmrestart.yaml +2 -0
  158. quadra-2.2.7/quadra/configs/scheduler/warmup.yaml +6 -0
  159. quadra-2.2.7/quadra/configs/task/anomalib/cfa.yaml +5 -0
  160. quadra-2.2.7/quadra/configs/task/anomalib/cflow.yaml +5 -0
  161. quadra-2.2.7/quadra/configs/task/anomalib/csflow.yaml +5 -0
  162. quadra-2.2.7/quadra/configs/task/anomalib/draem.yaml +5 -0
  163. quadra-2.2.7/quadra/configs/task/anomalib/efficient_ad.yaml +5 -0
  164. quadra-2.2.7/quadra/configs/task/anomalib/fastflow.yaml +5 -0
  165. quadra-2.2.7/quadra/configs/task/anomalib/inference.yaml +3 -0
  166. quadra-2.2.7/quadra/configs/task/anomalib/padim.yaml +5 -0
  167. quadra-2.2.7/quadra/configs/task/anomalib/patchcore.yaml +5 -0
  168. quadra-2.2.7/quadra/configs/task/classification.yaml +6 -0
  169. quadra-2.2.7/quadra/configs/task/classification_evaluation.yaml +6 -0
  170. quadra-2.2.7/quadra/configs/task/default.yaml +1 -0
  171. quadra-2.2.7/quadra/configs/task/segmentation.yaml +9 -0
  172. quadra-2.2.7/quadra/configs/task/segmentation_evaluation.yaml +3 -0
  173. quadra-2.2.7/quadra/configs/task/sklearn_classification.yaml +13 -0
  174. quadra-2.2.7/quadra/configs/task/sklearn_classification_patch.yaml +11 -0
  175. quadra-2.2.7/quadra/configs/task/sklearn_classification_patch_test.yaml +8 -0
  176. quadra-2.2.7/quadra/configs/task/sklearn_classification_test.yaml +8 -0
  177. quadra-2.2.7/quadra/configs/task/ssl.yaml +2 -0
  178. quadra-2.2.7/quadra/configs/trainer/lightning_cpu.yaml +36 -0
  179. quadra-2.2.7/quadra/configs/trainer/lightning_gpu.yaml +35 -0
  180. quadra-2.2.7/quadra/configs/trainer/lightning_gpu_bf16.yaml +36 -0
  181. quadra-2.2.7/quadra/configs/trainer/lightning_gpu_fp16.yaml +36 -0
  182. quadra-2.2.7/quadra/configs/trainer/lightning_multigpu.yaml +37 -0
  183. quadra-2.2.7/quadra/configs/trainer/sklearn_classification.yaml +7 -0
  184. quadra-2.2.7/quadra/configs/transforms/byol.yaml +47 -0
  185. quadra-2.2.7/quadra/configs/transforms/byol_no_random_resize.yaml +61 -0
  186. quadra-2.2.7/quadra/configs/transforms/default.yaml +37 -0
  187. quadra-2.2.7/quadra/configs/transforms/default_numpy.yaml +24 -0
  188. quadra-2.2.7/quadra/configs/transforms/default_resize.yaml +22 -0
  189. quadra-2.2.7/quadra/configs/transforms/dino.yaml +63 -0
  190. quadra-2.2.7/quadra/configs/transforms/linear_eval.yaml +18 -0
  191. quadra-2.2.7/quadra/datamodules/__init__.py +20 -0
  192. quadra-2.2.7/quadra/datamodules/anomaly.py +180 -0
  193. quadra-2.2.7/quadra/datamodules/base.py +375 -0
  194. quadra-2.2.7/quadra/datamodules/classification.py +1003 -0
  195. quadra-2.2.7/quadra/datamodules/generic/__init__.py +0 -0
  196. quadra-2.2.7/quadra/datamodules/generic/imagenette.py +144 -0
  197. quadra-2.2.7/quadra/datamodules/generic/mnist.py +81 -0
  198. quadra-2.2.7/quadra/datamodules/generic/mvtec.py +58 -0
  199. quadra-2.2.7/quadra/datamodules/generic/oxford_pet.py +163 -0
  200. quadra-2.2.7/quadra/datamodules/patch.py +190 -0
  201. quadra-2.2.7/quadra/datamodules/segmentation.py +742 -0
  202. quadra-2.2.7/quadra/datamodules/ssl.py +140 -0
  203. quadra-2.2.7/quadra/datasets/__init__.py +17 -0
  204. quadra-2.2.7/quadra/datasets/anomaly.py +287 -0
  205. quadra-2.2.7/quadra/datasets/classification.py +241 -0
  206. quadra-2.2.7/quadra/datasets/patch.py +138 -0
  207. quadra-2.2.7/quadra/datasets/segmentation.py +239 -0
  208. quadra-2.2.7/quadra/datasets/ssl.py +110 -0
  209. quadra-2.2.7/quadra/losses/__init__.py +0 -0
  210. quadra-2.2.7/quadra/losses/classification/__init__.py +6 -0
  211. quadra-2.2.7/quadra/losses/classification/asl.py +83 -0
  212. quadra-2.2.7/quadra/losses/classification/focal.py +320 -0
  213. quadra-2.2.7/quadra/losses/classification/prototypical.py +148 -0
  214. quadra-2.2.7/quadra/losses/ssl/__init__.py +17 -0
  215. quadra-2.2.7/quadra/losses/ssl/barlowtwins.py +47 -0
  216. quadra-2.2.7/quadra/losses/ssl/byol.py +37 -0
  217. quadra-2.2.7/quadra/losses/ssl/dino.py +129 -0
  218. quadra-2.2.7/quadra/losses/ssl/hyperspherical.py +45 -0
  219. quadra-2.2.7/quadra/losses/ssl/idmm.py +50 -0
  220. quadra-2.2.7/quadra/losses/ssl/simclr.py +67 -0
  221. quadra-2.2.7/quadra/losses/ssl/simsiam.py +30 -0
  222. quadra-2.2.7/quadra/losses/ssl/vicreg.py +76 -0
  223. quadra-2.2.7/quadra/main.py +49 -0
  224. quadra-2.2.7/quadra/metrics/__init__.py +3 -0
  225. quadra-2.2.7/quadra/metrics/segmentation.py +251 -0
  226. quadra-2.2.7/quadra/models/__init__.py +0 -0
  227. quadra-2.2.7/quadra/models/base.py +151 -0
  228. quadra-2.2.7/quadra/models/classification/__init__.py +8 -0
  229. quadra-2.2.7/quadra/models/classification/backbones.py +149 -0
  230. quadra-2.2.7/quadra/models/classification/base.py +92 -0
  231. quadra-2.2.7/quadra/models/evaluation.py +322 -0
  232. quadra-2.2.7/quadra/modules/__init__.py +0 -0
  233. quadra-2.2.7/quadra/modules/backbone.py +30 -0
  234. quadra-2.2.7/quadra/modules/base.py +312 -0
  235. quadra-2.2.7/quadra/modules/classification/__init__.py +3 -0
  236. quadra-2.2.7/quadra/modules/classification/base.py +327 -0
  237. quadra-2.2.7/quadra/modules/ssl/__init__.py +17 -0
  238. quadra-2.2.7/quadra/modules/ssl/barlowtwins.py +59 -0
  239. quadra-2.2.7/quadra/modules/ssl/byol.py +172 -0
  240. quadra-2.2.7/quadra/modules/ssl/common.py +285 -0
  241. quadra-2.2.7/quadra/modules/ssl/dino.py +186 -0
  242. quadra-2.2.7/quadra/modules/ssl/hyperspherical.py +206 -0
  243. quadra-2.2.7/quadra/modules/ssl/idmm.py +98 -0
  244. quadra-2.2.7/quadra/modules/ssl/simclr.py +73 -0
  245. quadra-2.2.7/quadra/modules/ssl/simsiam.py +68 -0
  246. quadra-2.2.7/quadra/modules/ssl/vicreg.py +67 -0
  247. quadra-2.2.7/quadra/optimizers/__init__.py +4 -0
  248. quadra-2.2.7/quadra/optimizers/lars.py +153 -0
  249. quadra-2.2.7/quadra/optimizers/sam.py +127 -0
  250. quadra-2.2.7/quadra/schedulers/__init__.py +3 -0
  251. quadra-2.2.7/quadra/schedulers/base.py +44 -0
  252. quadra-2.2.7/quadra/schedulers/warmup.py +127 -0
  253. quadra-2.2.7/quadra/tasks/__init__.py +24 -0
  254. quadra-2.2.7/quadra/tasks/anomaly.py +582 -0
  255. quadra-2.2.7/quadra/tasks/base.py +397 -0
  256. quadra-2.2.7/quadra/tasks/classification.py +1263 -0
  257. quadra-2.2.7/quadra/tasks/patch.py +492 -0
  258. quadra-2.2.7/quadra/tasks/segmentation.py +389 -0
  259. quadra-2.2.7/quadra/tasks/ssl.py +560 -0
  260. quadra-2.2.7/quadra/trainers/README.md +3 -0
  261. quadra-2.2.7/quadra/trainers/__init__.py +0 -0
  262. quadra-2.2.7/quadra/trainers/classification.py +179 -0
  263. quadra-2.2.7/quadra/utils/__init__.py +0 -0
  264. quadra-2.2.7/quadra/utils/anomaly.py +112 -0
  265. quadra-2.2.7/quadra/utils/classification.py +618 -0
  266. quadra-2.2.7/quadra/utils/deprecation.py +31 -0
  267. quadra-2.2.7/quadra/utils/evaluation.py +474 -0
  268. quadra-2.2.7/quadra/utils/export.py +585 -0
  269. quadra-2.2.7/quadra/utils/imaging.py +32 -0
  270. quadra-2.2.7/quadra/utils/logger.py +15 -0
  271. quadra-2.2.7/quadra/utils/mlflow.py +98 -0
  272. quadra-2.2.7/quadra/utils/model_manager.py +320 -0
  273. quadra-2.2.7/quadra/utils/models.py +523 -0
  274. quadra-2.2.7/quadra/utils/patch/__init__.py +15 -0
  275. quadra-2.2.7/quadra/utils/patch/dataset.py +1433 -0
  276. quadra-2.2.7/quadra/utils/patch/metrics.py +449 -0
  277. quadra-2.2.7/quadra/utils/patch/model.py +153 -0
  278. quadra-2.2.7/quadra/utils/patch/visualization.py +217 -0
  279. quadra-2.2.7/quadra/utils/resolver.py +42 -0
  280. quadra-2.2.7/quadra/utils/segmentation.py +31 -0
  281. quadra-2.2.7/quadra/utils/tests/__init__.py +0 -0
  282. quadra-2.2.7/quadra/utils/tests/fixtures/__init__.py +1 -0
  283. quadra-2.2.7/quadra/utils/tests/fixtures/dataset/__init__.py +39 -0
  284. quadra-2.2.7/quadra/utils/tests/fixtures/dataset/anomaly.py +124 -0
  285. quadra-2.2.7/quadra/utils/tests/fixtures/dataset/classification.py +406 -0
  286. quadra-2.2.7/quadra/utils/tests/fixtures/dataset/imagenette.py +53 -0
  287. quadra-2.2.7/quadra/utils/tests/fixtures/dataset/segmentation.py +161 -0
  288. quadra-2.2.7/quadra/utils/tests/fixtures/models/__init__.py +3 -0
  289. quadra-2.2.7/quadra/utils/tests/fixtures/models/anomaly.py +89 -0
  290. quadra-2.2.7/quadra/utils/tests/fixtures/models/classification.py +45 -0
  291. quadra-2.2.7/quadra/utils/tests/fixtures/models/segmentation.py +33 -0
  292. quadra-2.2.7/quadra/utils/tests/helpers.py +70 -0
  293. quadra-2.2.7/quadra/utils/tests/models.py +27 -0
  294. quadra-2.2.7/quadra/utils/utils.py +525 -0
  295. quadra-2.2.7/quadra/utils/validator.py +115 -0
  296. quadra-2.2.7/quadra/utils/visualization.py +422 -0
  297. quadra-2.2.7/quadra/utils/vit_explainability.py +349 -0
  298. quadra-2.2.7/quadra_hydra_plugin/hydra_plugins/quadra_searchpath_plugin.py +30 -0
  299. quadra-0.0.1/PKG-INFO +0 -14
  300. quadra-0.0.1/README.md +0 -1
  301. quadra-0.0.1/pyproject.toml +0 -14
  302. quadra-0.0.1/setup.py +0 -26
  303. {quadra-0.0.1/quadra → quadra-2.2.7/quadra/callbacks}/__init__.py +0 -0
quadra-2.2.7/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2023] Orobix Srl
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
quadra-2.2.7/PKG-INFO ADDED
@@ -0,0 +1,381 @@
1
+ Metadata-Version: 2.1
2
+ Name: quadra
3
+ Version: 2.2.7
4
+ Summary: Deep Learning experiment orchestration library
5
+ Home-page: https://orobix.github.io/quadra
6
+ License: Apache-2.0
7
+ Keywords: deep learning,experiment,lightning,hydra-core
8
+ Author: Federico Belotti
9
+ Author-email: federico.belotti@orobix.com
10
+ Requires-Python: >=3.9,<3.11
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Education
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Software Development
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Provides-Extra: onnx
23
+ Requires-Dist: albumentations (>=1.3,<1.4)
24
+ Requires-Dist: anomalib-orobix (==0.7.0.dev143)
25
+ Requires-Dist: boto3 (>=1.26,<1.27)
26
+ Requires-Dist: grad-cam-orobix (==1.5.3.dev001)
27
+ Requires-Dist: h5py (>=3.8,<3.9)
28
+ Requires-Dist: hydra_colorlog (>=1.2,<1.3)
29
+ Requires-Dist: hydra_core (>=1.3,<1.4)
30
+ Requires-Dist: hydra_optuna_sweeper (>=1.2,<1.3)
31
+ Requires-Dist: label_studio_converter (>=0.0,<0.1)
32
+ Requires-Dist: matplotlib (>=3.6,<3.7)
33
+ Requires-Dist: minio (>=7.1,<7.2)
34
+ Requires-Dist: mlflow-skinny (>=2.3.1,<3.0.0)
35
+ Requires-Dist: nvitop (>=0.11,<0.12)
36
+ Requires-Dist: onnx (==1.15.0) ; extra == "onnx"
37
+ Requires-Dist: onnxconverter-common (>=1.14.0,<2.0.0) ; extra == "onnx"
38
+ Requires-Dist: onnxruntime_gpu (==1.17.0) ; extra == "onnx"
39
+ Requires-Dist: onnxsim (==0.4.28) ; extra == "onnx"
40
+ Requires-Dist: opencv_python_headless (>=4.7.0,<4.8.0)
41
+ Requires-Dist: pandas (<2.0)
42
+ Requires-Dist: pillow (>=9.3,<9.4)
43
+ Requires-Dist: pydantic (==1.10.10)
44
+ Requires-Dist: python_dotenv (>=0.21,<0.22)
45
+ Requires-Dist: pytorch_lightning (>=2.1,<2.2)
46
+ Requires-Dist: rich (>=13.2,<13.3)
47
+ Requires-Dist: scikit_learn (>=1.2,<1.3)
48
+ Requires-Dist: scikit_multilearn (>=0.2,<0.3)
49
+ Requires-Dist: seaborn (>=0.12,<0.13)
50
+ Requires-Dist: segmentation_models_pytorch-orobix (==0.3.3.dev1)
51
+ Requires-Dist: tensorboard (>=2.11,<2.12)
52
+ Requires-Dist: timm (==0.9.12)
53
+ Requires-Dist: torch (==2.1.2)
54
+ Requires-Dist: torchinfo (>=1.8,<1.9)
55
+ Requires-Dist: torchmetrics (>=0.10,<0.11)
56
+ Requires-Dist: torchsummary (>=1.5,<1.6)
57
+ Requires-Dist: torchvision (>=0.16,<0.17)
58
+ Requires-Dist: tripy (>=1.0,<1.1)
59
+ Requires-Dist: typing_extensions (==4.11.0) ; python_version < "3.10"
60
+ Requires-Dist: xxhash (>=3.2,<3.3)
61
+ Project-URL: Repository, https://github.com/orobix/quadra
62
+ Description-Content-Type: text/markdown
63
+
64
+ <h1></h1>
65
+ <p align="center">
66
+ <img src="https://github.com/orobix/quadra/raw/main/docs/images/quadra_text_logo.png" alt="Quadra Logo" width="100%">
67
+ </p>
68
+
69
+ <p align="center">
70
+ <a href="https://orobix.github.io/quadra/latest/index.html">Docs</a> •
71
+ <a href="https://orobix.github.io/quadra/latest/tutorials/datamodules.html">Tutorials</a> •
72
+ <a href="https://orobix.github.io/quadra/latest/tutorials/configurations.html">Configurations</a>
73
+ </p>
74
+
75
+ <div align="center">
76
+ <a href="https://github.com/astral-sh/ruff">
77
+ <img
78
+ src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json"
79
+ alt="ruff"
80
+ ></a>
81
+ <a href="https://github.com/pre-commit/pre-commit"><img
82
+ src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white"
83
+ alt="pre-commit"
84
+ /></a>
85
+ <a href="https://github.com/econchick/interrogate"><img
86
+ src="https://github.com/orobix/quadra/raw/main/docs/images/interrogate_badge.svg"
87
+ alt="interrogate"
88
+ /></a>
89
+ <a href="https://github.com/PyCQA/pylint"><img
90
+ src="https://img.shields.io/badge/linting-pylint-yellowgreen"
91
+ alt="pylint"
92
+ /></a>
93
+ <a href="https://mypy-lang.org/"><img
94
+ src="https://www.mypy-lang.org/static/mypy_badge.svg"
95
+ alt="Checked with mypy"
96
+ /></a>
97
+
98
+ </div>
99
+
100
+ ______________________________________________________________________
101
+
102
+
103
+ `Quadra` aims to simplify deep learning experimenting process, allowing researchers or developers to compare, monitor, and share their experiments quickly. It provides a simple and flexible way to train and deploy deep learning models using YAML configuration files and open-source tools such as [Hydra](https://hydra.cc/docs/intro/), [Lightning](https://www.pytorchlightning.ai/index.html) framework, and [Pytorch](https://pytorch.org/). It lets you compose your experiment configurations from single command line interface, so you can conduct multiple experiments with different settings and hyperparameters. Every experiment can be logged using integrations provided by [Lightning](https://www.pytorchlightning.ai/index.html) framework such [Mlflow](https://mlflow.org/).
104
+
105
+
106
+ ## Quick Start Guide
107
+
108
+ If you use pip to manage your packages, you can install `quadra` from PyPi by running the following command:
109
+ ```shell
110
+ pip install quadra
111
+ ```
112
+
113
+ If instead you prefer to use poetry, you can install `quadra` from PyPi by running the following command:
114
+ ```shell
115
+ poetry add quadra
116
+ ```
117
+
118
+ If you don't have virtual environment ready, Let's set up our environment for using the `quadra` library. We have two parts in this guide: Common setup and Environment-specific setup.
119
+
120
+ ### Using Conda
121
+
122
+ Create and activate a new `Conda` environment.
123
+
124
+ ```shell
125
+ conda create -n myenv python=3.10
126
+ conda activate myenv
127
+ ```
128
+
129
+ ### Using Python Virtualenv
130
+
131
+ Create and activate a new virtual environment.
132
+
133
+ ```shell
134
+ # replace `myenv` with the name of your virtual environment
135
+ python3 -m venv myenv
136
+ source myenv/bin/activate
137
+ ```
138
+
139
+ ### Common Setup
140
+
141
+ 1. **Check your git version**:
142
+ Make sure you have git version 2.10 or higher, to avoid any installation failures.
143
+ ```shell
144
+ git --version
145
+ ```
146
+
147
+ 2. **Upgrade pip**:
148
+ ```shell
149
+ pip install --upgrade pip
150
+ ```
151
+
152
+ 3. Install the package
153
+
154
+ * **Install the `quadra` package** with pip:
155
+ ```shell
156
+ pip install quadra
157
+ ```
158
+
159
+ * **Install the `quadra` package** with poetry:
160
+ ```shell
161
+ curl -sSL https://install.python-poetry.org | python3 -
162
+ poetry add quadra
163
+ ```
164
+
165
+ 4. **Run from CLI**:
166
+ Run the following command to check if the installation was successful:
167
+ ```shell
168
+ quadra experiment=default
169
+ ```
170
+
171
+ ### Setup `Mlflow` (Optional)
172
+
173
+ To use Mlflow and leverage its functionalities such as saving models, logging metrics, saving artifacts, and visualizing results, you need to ensure that the Mlflow server is running. You can find more information about Mlflow [here](https://mlflow.org/).
174
+
175
+ By default, the logger configuration is set to Mlflow, and experiments expect the `MLFLOW_TRACKING_URI` environment variable to be set to the address of the Mlflow server. There are two ways to set this variable:
176
+
177
+ **Using the command line:**
178
+
179
+ ```
180
+ export MLFLOW_TRACKING_URI=http://localhost:5000
181
+ ```
182
+ This command sets the `MLFLOW_TRACKING_URI` variable to `http://localhost:5000`. Replace this with the actual address of your Mlflow server if it's running on a different host or port.
183
+
184
+ **Adding it to your environment file:**
185
+
186
+ `Quadra` uses environment variables to store credentials and other sensitive information. Thanks to [`python-dotenv`](https://pypi.org/project/python-dotenv/) library, you can create a `.env` file in the main folder of your project and store the credentials there. During the runtime, the library will automatically load the environment variables from the `.env` file. You can also add the `MLFLOW_TRACKING_URI` variable to your environment file (e.g., `.env`). Open the file in a text editor and add the following line:
187
+
188
+ ```
189
+ MLFLOW_TRACKING_URI=http://localhost:5000
190
+ ```
191
+ Again, modify the address if your Mlflow server is running on a different host or port.
192
+
193
+ By setting the `MLFLOW_TRACKING_URI` variable using either method, you configure the logger to connect to the Mlflow server, enabling you to utilize its features effectively.
194
+
195
+ The `export` command is specific to Unix-based systems like Linux or macOS. If you are using a different operating system, refer to the appropriate method for setting environment variables.
196
+
197
+ ## Run Example Experiments
198
+
199
+ `quadra` provides a set of example experiments that can be used to test the installation and to provide some example configuration files.
200
+
201
+ By default all the experiments will run on the `GPU 0`, to run it on the `CPU` you can specify a different `trainer` configuration parameter:
202
+
203
+ ```bash
204
+ quadra <configurations> trainer=lightning_cpu
205
+ ```
206
+
207
+ ### Classification Training
208
+
209
+ To run a simple classification training on the [Imagenette dataset](https://github.com/fastai/imagenette) with a Resnet18 architecture run the following command:
210
+
211
+ ```bash
212
+ quadra experiment=generic/imagenette/classification/default logger=csv
213
+ ```
214
+
215
+ This will train the model for 20 epochs and log the metrics in a csv file, at the end of the training a `torchscript` model will be saved for inference alongside some output images.
216
+
217
+ By default the experiment will run on the GPU 0, to run it on the CPU you can specify a different `trainer` configuration parameter.
218
+
219
+
220
+ ### Segmentation Training
221
+
222
+ To run a simple segmentation training on the [Oxford pet](https://www.robots.ox.ac.uk/~vgg/data/pets/) dataset with a Unet architecture run the following command:
223
+
224
+ ```bash
225
+ quadra experiment=generic/oxford_pet/segmentation/smp logger=csv
226
+ ```
227
+
228
+ This will make use of the [segmentation models pytorch](https://github.com/qubvel/segmentation_models.pytorch) library to train the model for 10 epochs, logging the metrics to a csv file. At the end of the training a torchscript model will be saved for inference alongside some output images.
229
+
230
+ ### (SSL) Self-supervised Learning Training
231
+
232
+ On the same dataset we can run a simple SSL training using the BYOL algorithm with the following command:
233
+
234
+ ```bash
235
+ quadra experiment=generic/imagenette/ssl/byol logger=csv
236
+ ```
237
+
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
+
240
+
241
+ ### Anomaly Detection Training
242
+
243
+ To run a simple anomaly detection training on the [MNIST dataset](http://yann.lecun.com/exdb/mnist/) using the PADIM algorithm run the following command:
244
+
245
+ ```bash
246
+ quadra experiment=generic/mnist/anomaly/padim logger=csv
247
+ ```
248
+
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
+
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
+
253
+ ## Running with Custom Datasets
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/configs/experiment/base/<task>/<config_name>.yaml`.
256
+
257
+ Let's see how we can customize the configuration file to run the classification experiment on a custom dataset.
258
+
259
+ Structure your dataset in the following way:
260
+
261
+ ```tree
262
+ dataset/
263
+ ├── class_1
264
+ │ ├── abc.xyz
265
+ │ └── ...
266
+ ├── class_2
267
+ │ ├── abc.xyz
268
+ │ └── ...
269
+ ├── class_3
270
+ │ ├── abc.xyz
271
+ │ └── ...
272
+ ```
273
+
274
+ Create a new experiment configuration file under `quadra/configs/experiment/custom/<config_name>.yaml` with the following content:
275
+
276
+ ```yaml
277
+ # @package _global_
278
+ defaults:
279
+ - base/classification/classification # extends the default classification configuration
280
+
281
+ core:
282
+ name: <your-custom-experiment-name> # name of the experiment
283
+
284
+ model:
285
+ num_classes: <number-of_classes-you-have> # number of classes in your dataset
286
+ ```
287
+
288
+ Run the experiment with the following command:
289
+
290
+ ```bash
291
+ quadra experiment=custom/<config_name> logger=csv
292
+ ```
293
+
294
+ It will run the experiment using the configuration file you have just created and it will apply the default parameters from the classification configuration file. Furthermore, it will log the metrics to a csv file. You can add or customize the parameters in the configuration file to fit your needs.
295
+
296
+ For more information about advanced usage, please check [tutorials](https://orobix.github.io/quadra/latest/tutorials/configurations.html) and [task specific examples](https://orobix.github.io/quadra/latest/tutorials/examples/classification.html).
297
+
298
+ ## Development
299
+
300
+ First clone the repository from Github
301
+
302
+ First clone the repository from `Github`, then we need to install the package with optional dependencies (generally in editable mode) and enable the pre-commit hooks.
303
+
304
+ 1. `git clone https://github.com/orobix/quadra.git && cd quadra`
305
+ 2. Install poetry `curl -sSL https://install.python-poetry.org | python3 -`
306
+ 3. Install the required poetry plugins
307
+ ```
308
+ poetry self add poetry-bumpversion
309
+ poetry self add poetry-dotenv-plugin
310
+ ```
311
+ 4. Install `quadra` package in editable mode `poetry install --with test,dev,docs --all-extras`
312
+ 5. Install pre-commit hooks `pre-commit install`
313
+ 6. (Optional) Eventually build documentation by calling required commands (see below).
314
+
315
+ Now you can start developing and the pre-commit hooks will run automatically to prevent you from committing code that does not pass the linting and formatting checks.
316
+
317
+ We rely on a combination of `Pylint`, `Mypy` and `Ruff` to enforce code quality.
318
+
319
+ ## Building Documentations
320
+
321
+ 1. Activate your virtual environment.
322
+ 2. Install the `quadra` package with at least `doc` version.
323
+ 3. To run the webserver for real-time rendering and editing run `mkdocs serve` and visit `http://localhost:8000/`.
324
+ 4. If you want to export the static website to a specific folder `mkdocs build -d <Destination Folder>`
325
+
326
+
327
+ ## Acknowledgements
328
+
329
+ This project is based on many open-source libraries and frameworks, we would like to thank all the contributors for their work. Here is a list of the main libraries and frameworks we use:
330
+
331
+ - [Pytorch](https://pytorch.org/) and [Pytorch Lightning](https://lightning.ai/) for training and deploying deep learning models. These two libraries are core part of training and testing tasks that allow us to run experiments on different devices in agile way.
332
+ - Pretrained models are usually loaded from [Pytorch Hub](https://pytorch.org/hub/) or [Pytorch-image-models](https://github.com/huggingface/pytorch-image-models) (or called as `timm`).
333
+ - Each specific task may rely on different libraries. For example, `segmentation` task uses [Segmentation_models.pytorch](https://github.com/qubvel/segmentation_models.pytorch) for loading backbones. The `anomaly detection` task uses a fork of [Anomalib](https://github.com/openvinotoolkit/anomalib) maintained by Orobix on [this repository](https://github.com/orobix/anomalib). We use light-weight ML models from [scikit-learn](https://scikit-learn.org/). We have also implementation of some SOTA models inside our library.
334
+ - Data processing and augmentation are done using [Albumentations](https://albumentations.ai/docs/) and [OpenCV](https://opencv.org/).
335
+ - [Hydra](https://hydra.cc/docs/intro/) for composing configurations and running experiments. Hydra is a powerful framework that allows us to compose configurations from command line interface and run multiple experiments with different settings and hyperparameters. We have followed suggestions from `Configuring Experiments` section of [Hydra documentation](https://hydra.cc/docs/patterns/configuring_experiments/) and [lightning-hydra-template](https://github.com/ashleve/lightning-hydra-template) repository.
336
+ - Documentation website is using [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) and [MkDocs](https://www.mkdocs.org/). For code documentation we are using [Mkdocstrings](https://mkdocstrings.github.io/). For releasing software versions we combine [Bumpver](https://github.com/mbarkhau/bumpver) and [Mike](https://github.com/jimporter/mike).
337
+ - Models can be exported in different ways (`torchscript` or `torch` file). We have also added [ONNX](https://onnx.ai/) support for some models.
338
+ - Testing framework is based on [Pytest](https://docs.pytest.org/en/) and related plug-ins.
339
+ - Code quality is ensured by [pre-commit](https://pre-commit.com/) hooks. We are using [Ruff](https://github.com/astral-sh/ruff) for linting, enforcing code quality and formatting, [Pylint](https://www.pylint.org/) for in depth linting and [Mypy](https://mypy.readthedocs.io/en/stable/) for type checking.
340
+
341
+ ## FAQ
342
+
343
+ **How can I fix errors related to `GL` when I install full `opencv` package?**
344
+
345
+ If you are running on a remote server without a display and you are using `opencv-python` instead of `opencv-python-headless` you can run the following command to fix the issue:
346
+
347
+ It can be solved by correctly linking the `libGL.so.1` library:
348
+
349
+ ```bash
350
+ # Check where the library is located
351
+ find /usr -name libGL.so.1
352
+ ```
353
+
354
+ ```bash
355
+ # if the library is located in /usr/lib/x86_64-linux-gnu
356
+ # link it to /usr/lib
357
+ sudo ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/libGL.so
358
+ ```
359
+
360
+ or installing following packages (depending on your OS this may vary):
361
+
362
+ ```bash
363
+ sudo apt-get install libgl1-mesa-glx
364
+ ```
365
+
366
+
367
+ **How can I run multiple experiments with single command?**
368
+
369
+ You can run multiple experiments with a single command by passing `--multirun` flag:
370
+
371
+ ```bash
372
+ quadra <configurations> --multirun
373
+ ```
374
+
375
+ For example if you want to run same experiment with different seeds you can run:
376
+
377
+ ```bash
378
+ quadra experiment=generic/imagenette/classification/default trainer=lightning_cpu logger=csv core.seed=1,2,3 --multirun
379
+ ```
380
+
381
+