lightly-train 0.3.0__tar.gz → 0.3.2__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 (190) hide show
  1. lightly_train-0.3.2/.github/workflows/README.md +68 -0
  2. lightly_train-0.3.2/.github/workflows/release_documentation.yml +80 -0
  3. lightly_train-0.3.2/.github/workflows/test_unit.yml +76 -0
  4. {lightly_train-0.3.0 → lightly_train-0.3.2}/MAINTAINING.md +3 -3
  5. {lightly_train-0.3.0 → lightly_train-0.3.2}/Makefile +9 -9
  6. {lightly_train-0.3.0/src/lightly_train.egg-info → lightly_train-0.3.2}/PKG-INFO +6 -6
  7. {lightly_train-0.3.0 → lightly_train-0.3.2}/README.md +5 -5
  8. {lightly_train-0.3.0 → lightly_train-0.3.2}/docker/Makefile +7 -7
  9. {lightly_train-0.3.0 → lightly_train-0.3.2}/docs/Makefile +8 -4
  10. {lightly_train-0.3.0 → lightly_train-0.3.2}/docs/source/_static/custom.css +2 -2
  11. {lightly_train-0.3.0 → lightly_train-0.3.2}/docs/source/_static/lightly_train.svg +1 -1
  12. lightly_train-0.3.2/docs/source/_templates/sidebar/version.html +1 -0
  13. lightly_train-0.3.2/docs/source/docker.md +62 -0
  14. lightly_train-0.3.2/docs/source/embed.md +100 -0
  15. lightly_train-0.3.2/docs/source/export.md +108 -0
  16. lightly_train-0.3.2/docs/source/index.md +147 -0
  17. lightly_train-0.3.2/docs/source/installation.md +46 -0
  18. lightly_train-0.3.2/docs/source/methods/index.md +25 -0
  19. lightly_train-0.3.2/docs/source/models/custom_models.md +144 -0
  20. lightly_train-0.3.2/docs/source/models/index.md +279 -0
  21. lightly_train-0.3.2/docs/source/quick_start.md +193 -0
  22. lightly_train-0.3.2/docs/source/train.md +233 -0
  23. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/__init__.py +1 -1
  24. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_cli.py +63 -41
  25. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/common_helpers.py +33 -10
  26. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/embed.py +10 -9
  27. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/export.py +18 -13
  28. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/extract_video_frames.py +1 -1
  29. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/train.py +80 -35
  30. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/train_helpers.py +107 -37
  31. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_data/image_dataset.py +8 -4
  32. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/densecl.py +3 -3
  33. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/densecldino.py +3 -3
  34. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/dino.py +2 -2
  35. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/method.py +49 -3
  36. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/method_helpers.py +4 -0
  37. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/simclr.py +2 -2
  38. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/custom/custom.py +1 -2
  39. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/custom/custom_package.py +2 -2
  40. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/embedding_model.py +10 -11
  41. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/feature_extractor.py +20 -22
  42. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/package.py +1 -1
  43. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/package_helpers.py +6 -3
  44. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/super_gradients/customizable_detector.py +0 -1
  45. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/super_gradients/segmentation_module.py +0 -1
  46. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/super_gradients/super_gradients_package.py +2 -2
  47. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/timm/timm.py +1 -2
  48. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/timm/timm_package.py +2 -2
  49. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/torchvision/convnext.py +1 -4
  50. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/torchvision/resnet.py +1 -4
  51. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/torchvision/torchvision.py +1 -1
  52. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/torchvision/torchvision_package.py +2 -2
  53. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/ultralytics/ultralytics.py +2 -3
  54. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/ultralytics/ultralytics_package.py +2 -2
  55. {lightly_train-0.3.0 → lightly_train-0.3.2/src/lightly_train.egg-info}/PKG-INFO +6 -6
  56. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train.egg-info/SOURCES.txt +13 -3
  57. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_commands/test_common_helpers.py +43 -3
  58. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_commands/test_embed.py +4 -4
  59. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_commands/test_train.py +63 -13
  60. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_commands/test_train_helpers.py +187 -24
  61. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_data/test_image_dataset.py +83 -13
  62. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/custom/test_custom.py +1 -1
  63. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/super_gradients/test_segmentation_module.py +6 -4
  64. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/super_gradients/test_super_gradients_package.py +7 -9
  65. lightly_train-0.3.2/tests/_models/test_embedding_model.py +49 -0
  66. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/test_package_helpers.py +1 -1
  67. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/timm/test_timm.py +2 -10
  68. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/ultralytics/test_ultralytics.py +1 -1
  69. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/ultralytics/test_ultralytics_package.py +3 -3
  70. lightly_train-0.3.2/tests/_transforms/__init__.py +7 -0
  71. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/helpers.py +20 -11
  72. lightly_train-0.3.0/.github/workflows/test_unit.yml +0 -56
  73. lightly_train-0.3.0/DOCS.md +0 -164
  74. lightly_train-0.3.0/docs/source/_templates/sidebar/version.html +0 -1
  75. lightly_train-0.3.0/docs/source/index.md +0 -11
  76. lightly_train-0.3.0/docs/source/installation.md +0 -5
  77. lightly_train-0.3.0/src/lightly_train/_models/embedding/base.py +0 -79
  78. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/pull_request_template.md +0 -0
  79. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/workflows/build_docker_image.yml +0 -0
  80. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/workflows/check_code_format.yml +0 -0
  81. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/workflows/release_dockerhub.yml +0 -0
  82. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/workflows/release_pypi.yml +0 -0
  83. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/workflows/test_docker.yml +0 -0
  84. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/workflows/test_unit_latest_dependencies.yml +0 -0
  85. {lightly_train-0.3.0 → lightly_train-0.3.2}/.github/workflows/test_unit_minimal_dependencies.yml +0 -0
  86. {lightly_train-0.3.0 → lightly_train-0.3.2}/.gitignore +0 -0
  87. {lightly_train-0.3.0 → lightly_train-0.3.2}/CONTRIBUTING.md +0 -0
  88. {lightly_train-0.3.0 → lightly_train-0.3.2}/LICENSE +0 -0
  89. {lightly_train-0.3.0 → lightly_train-0.3.2}/dev_tools/licenseheader.tmpl +0 -0
  90. {lightly_train-0.3.0 → lightly_train-0.3.2}/docker/Dockerfile-amd64-cuda +0 -0
  91. {lightly_train-0.3.0 → lightly_train-0.3.2}/docker/README.md +0 -0
  92. {lightly_train-0.3.0 → lightly_train-0.3.2}/docs/build.py +0 -0
  93. {lightly_train-0.3.0 → lightly_train-0.3.2}/docs/source/conf.py +0 -0
  94. {lightly_train-0.3.0 → lightly_train-0.3.2}/docs/source/python_api/index.md +0 -0
  95. {lightly_train-0.3.0 → lightly_train-0.3.2}/docs/source/python_api/lightly_train.md +0 -0
  96. {lightly_train-0.3.0 → lightly_train-0.3.2}/pyproject.toml +0 -0
  97. {lightly_train-0.3.0 → lightly_train-0.3.2}/setup.cfg +0 -0
  98. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_callbacks/__init__.py +0 -0
  99. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_callbacks/callback_args.py +0 -0
  100. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_callbacks/callback_helpers.py +0 -0
  101. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_callbacks/checkpoint.py +0 -0
  102. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_checkpoint.py +0 -0
  103. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/__init__.py +0 -0
  104. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_commands/_warnings.py +0 -0
  105. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_configs/__init__.py +0 -0
  106. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_configs/config.py +0 -0
  107. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_configs/omegaconf_utils.py +0 -0
  108. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_configs/validate.py +0 -0
  109. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_constants.py +0 -0
  110. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_data/__init__.py +0 -0
  111. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_data/_serialize/__init__.py +0 -0
  112. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_data/_serialize/memory_mapped_sequence.py +0 -0
  113. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/__init__.py +0 -0
  114. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/embedding_format.py +0 -0
  115. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/embedding_predictor.py +0 -0
  116. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/embedding_transform.py +0 -0
  117. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/writers/__init__.py +0 -0
  118. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/writers/csv_writer.py +0 -0
  119. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/writers/embedding_writer.py +0 -0
  120. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/writers/torch_writer.py +0 -0
  121. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_embedding/writers/writer_helpers.py +0 -0
  122. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_loggers/__init__.py +0 -0
  123. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_loggers/jsonl.py +0 -0
  124. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_loggers/logger_args.py +0 -0
  125. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_loggers/logger_helpers.py +0 -0
  126. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_loggers/tensorboard.py +0 -0
  127. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_loggers/wandb.py +0 -0
  128. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_logging.py +0 -0
  129. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/__init__.py +0 -0
  130. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_methods/method_args.py +0 -0
  131. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/__init__.py +0 -0
  132. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/custom/__init__.py +0 -0
  133. {lightly_train-0.3.0/src/lightly_train/_models/embedding → lightly_train-0.3.2/src/lightly_train/_models/super_gradients}/__init__.py +0 -0
  134. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_models/super_gradients/super_gradients.py +0 -0
  135. {lightly_train-0.3.0/src/lightly_train/_models/super_gradients → lightly_train-0.3.2/src/lightly_train/_models/timm}/__init__.py +0 -0
  136. {lightly_train-0.3.0/src/lightly_train/_models/timm → lightly_train-0.3.2/src/lightly_train/_models/torchvision}/__init__.py +0 -0
  137. {lightly_train-0.3.0/src/lightly_train/_models/torchvision → lightly_train-0.3.2/src/lightly_train/_models/ultralytics}/__init__.py +0 -0
  138. {lightly_train-0.3.0/src/lightly_train/_models/ultralytics → lightly_train-0.3.2/src/lightly_train/_optim}/__init__.py +0 -0
  139. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_optim/adamw_args.py +0 -0
  140. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_optim/optimizer.py +0 -0
  141. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_optim/optimizer_args.py +0 -0
  142. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_optim/optimizer_type.py +0 -0
  143. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_optim/trainable_modules.py +0 -0
  144. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_plot.py +0 -0
  145. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_scaling.py +0 -0
  146. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_transforms/to_tensor.py +0 -0
  147. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/_transforms/transform.py +0 -0
  148. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/errors.py +0 -0
  149. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train/types.py +0 -0
  150. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train.egg-info/dependency_links.txt +0 -0
  151. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train.egg-info/entry_points.txt +0 -0
  152. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train.egg-info/requires.txt +0 -0
  153. {lightly_train-0.3.0 → lightly_train-0.3.2}/src/lightly_train.egg-info/top_level.txt +0 -0
  154. {lightly_train-0.3.0/src/lightly_train/_optim → lightly_train-0.3.2/tests}/__init__.py +0 -0
  155. {lightly_train-0.3.0/tests → lightly_train-0.3.2/tests/_callbacks}/__init__.py +0 -0
  156. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_callbacks/test_callback_helpers.py +0 -0
  157. {lightly_train-0.3.0/tests/_callbacks → lightly_train-0.3.2/tests/_commands}/__init__.py +0 -0
  158. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_commands/test_export.py +0 -0
  159. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_commands/test_extract_video_frames.py +0 -0
  160. {lightly_train-0.3.0/tests/_commands → lightly_train-0.3.2/tests/_configs}/__init__.py +0 -0
  161. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_configs/test_config.py +0 -0
  162. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_configs/test_validate.py +0 -0
  163. {lightly_train-0.3.0/tests/_configs → lightly_train-0.3.2/tests/_data}/__init__.py +0 -0
  164. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_data/_serialize/test_memory_mapped_sequence.py +0 -0
  165. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_embedding/__init__.py +0 -0
  166. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_embedding/writers/__init__.py +0 -0
  167. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_embedding/writers/test_csv_writer.py +0 -0
  168. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_embedding/writers/test_torch_writer.py +0 -0
  169. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_embedding/writers/test_writer_helpers.py +0 -0
  170. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_loggers/test_logger_helpers.py +0 -0
  171. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_methods/__init__.py +0 -0
  172. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_methods/test_densecl.py +0 -0
  173. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_methods/test_densecldino.py +0 -0
  174. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_methods/test_dino.py +0 -0
  175. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_methods/test_method_helpers.py +0 -0
  176. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_methods/test_simclr.py +0 -0
  177. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/__init__.py +0 -0
  178. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/custom/__init__.py +0 -0
  179. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/custom/test_custom_package.py +0 -0
  180. {lightly_train-0.3.0/tests/_models/timm → lightly_train-0.3.2/tests/_models/super_gradients}/__init__.py +0 -0
  181. {lightly_train-0.3.0/tests/_optim → lightly_train-0.3.2/tests/_models/timm}/__init__.py +0 -0
  182. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/timm/test_timm_package.py +0 -0
  183. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_models/torchvision/test_torchvision_package.py +0 -0
  184. {lightly_train-0.3.0/tests/_transforms → lightly_train-0.3.2/tests/_optim}/__init__.py +0 -0
  185. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/_optim/test_optimizer.py +0 -0
  186. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/test__checkpoint.py +0 -0
  187. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/test__cli.py +0 -0
  188. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/test__logging.py +0 -0
  189. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/test__plot.py +0 -0
  190. {lightly_train-0.3.0 → lightly_train-0.3.2}/tests/test__scaling.py +0 -0
@@ -0,0 +1,68 @@
1
+ # Workflows for GitHub Actions
2
+
3
+ ## Caching With UV
4
+
5
+ Our actions have a special setup because we use self-hosted runners which are persistent
6
+ across jobs. This requires some attention on how caching and environments are set up.
7
+
8
+ References:
9
+
10
+ - https://docs.astral.sh/uv/concepts/cache/#caching
11
+ - https://docs.astral.sh/uv/configuration/environment/
12
+ - https://github.com/astral-sh/setup-uv?tab=readme-ov-file#usage
13
+
14
+ ### Environment Variables
15
+
16
+ - `VIRTUAL_ENV`
17
+ - This variable sets the path to the virtual environment. This is not a variable by uv
18
+ but is respected by it.
19
+ - We set this to `${{ github.workspace }}/.venv` which corresponds to the `.venv`
20
+ directory in the repository root.
21
+ - Virtual environments are not persistent across jobs as GitHub Actions creates a new
22
+ `${{ github.workspace }}` for every job.
23
+ - We still want to use a virtual environment and not install into the system Python
24
+ environment with `UV_SYSTEM_PYTHON=1` because the system Python environment is
25
+ persistent across jobs due to the self-hosted runner setup.
26
+ - Uv automatically uses `VIRTUAL_ENV` for its commands (you don't have to call
27
+ `source .venv/bin/activate` before). But not all other tools respect it.
28
+ For example, pytest still requires the environment to be activated. We activate the
29
+ environment by adding it to the `GITHUB_PATH` variable instead of calling
30
+ `source .venv/bin/activate`. This is required because GitHub Actions requires that
31
+ `source .venv/bin/activate` is called in every step as environment variables are not
32
+ persisted across steps. By adding the environment to `GITHUB_PATH`, we can skip the
33
+ activation in every step.
34
+ - `UV_CACHE_DIR`
35
+ - This variable determines where uv creates its cache.
36
+ - It is set by the `cache-local-path` setting in the `astral-sh/setup-uv` action.
37
+ - Must be set to a directory that is persistent across jobs. We set it to
38
+ `/tmp/setup-uv-cache` which means that the cache is persistent as long as the
39
+ self-hosted runner is not restarted (`/tmp` is not a mounted volume).
40
+ - We don't have to worry about the cache too much. Uv handles it automatically.
41
+ It is also save regarding multi-threading, different uv/python versions, and minimal
42
+ dependencies etc.
43
+ See: https://docs.astral.sh/uv/concepts/cache/#cache-safety
44
+ - The variable is automatically used by uv. We don't have to specify it in commands.
45
+
46
+ ### Environment Information
47
+
48
+ - The environment is in `${{ github.workspace }}/.venv` which corresponds to the `.venv`
49
+ directory in the repository root (same as for local development). The environment is
50
+ not persistent across jobs.
51
+ - The cache is in `/tmp/setup-uv-cache` which is persistent across jobs. Restart the
52
+ runner to clear the cache.
53
+ - Python is installed to `/gh-actions/_work/_tool/Python/3` which is persistent across
54
+ jobs.
55
+
56
+ ### astral-sh/setup-uv Action Information
57
+
58
+ - `cache-local-path` sets the cache directory (`UV_CACHE_DIR`). See `UV_CACHE_DIR` above
59
+ for more information.
60
+ - `prune-cache: false` disables cache pruning. Cache pruning is efficient for GitHub
61
+ hosted action runners but not for self-hosted runners.
62
+ See: https://github.com/astral-sh/setup-uv?tab=readme-ov-file#disable-cache-pruning
63
+ - `enable_cache: true` is NOT set in the action settings. This is because we use a
64
+ local cache. `enable_cache` only makes sense in combination with GitHub Actions
65
+ Cache (`actions/cache`) and would upload the cache to GitHub.
66
+ - `cache-dependency-glob` is NOT set in the action settings. My understanding
67
+ (Guarin, 10/24) is that this is also only used in combination with GitHub Actions
68
+ Cache (`actions/cache`) and would determine when the cache is invalidated.
@@ -0,0 +1,80 @@
1
+ name: Release Documentation
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ release-documentation:
8
+ name: Build and release documentation
9
+ runs-on: cpu
10
+ steps:
11
+ - name: Checkout code
12
+ uses: actions/checkout@v4
13
+ with:
14
+ fetch-depth: 0
15
+ - name: Checkout latest release tag
16
+ id: checkout_latest_release_tag
17
+ run: |
18
+ LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
19
+ git checkout $LATEST_TAG
20
+ echo "tag_name=$LATEST_TAG" >> $GITHUB_OUTPUT;
21
+ - name: Assert version in code matches latest release tag
22
+ id: assert_version
23
+ run: |
24
+ LATEST_TAG=${{steps.checkout_latest_release_tag.outputs.tag_name}}
25
+ VERSION_FROM_INIT=$(grep -oP '(?<=__version__ = ")[^"]*' src/lightly_train/__init__.py)
26
+ VERSION_FROM_INIT="v$VERSION_FROM_INIT"
27
+ if [ "$VERSION_FROM_INIT" != "$LATEST_TAG" ]; then
28
+ echo "Version mismatch: Tag is $LATEST_TAG, but __version__ in __init__.py is $VERSION_FROM_INIT"
29
+ exit 1
30
+ fi
31
+ echo "__version__ from __init__.py $VERSION_FROM_INIT matches latest tag $LATEST_TAG"
32
+ - name: Set up Python 3.10
33
+ uses: actions/setup-python@v5
34
+ with:
35
+ python-version: "3.10"
36
+ - name: Set Up Environment
37
+ run: |
38
+ make install-uv reset-venv
39
+ source .venv/bin/activate
40
+ make install-dev
41
+ - name: Authenticate with GCP
42
+ id: auth-gcp
43
+ uses: 'google-github-actions/auth@v2'
44
+ with:
45
+ project_id: ${{ secrets.GCP_PROJECT_ID }}
46
+ credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
47
+ - name: Build
48
+ run: |
49
+ source .venv/bin/activate
50
+ cd docs && make docs docs-stable
51
+ - name: Release
52
+ id: build_and_release
53
+ run: |
54
+ gsutil -m rsync -r ./docs/build gs://docs-pip/lightly-train/build
55
+ gcloud compute scp \
56
+ --zone ${{ secrets.DOCS_INSTANCE_ZONE }} \
57
+ --recurse ./docs/build/* ${{ secrets.DOCS_INSTANCE_ID }}:${{ secrets.DOCS_INSTANCE_DIR }}/lightly-train/docs/build
58
+ - name: Convert success/failure strings to emojis
59
+ if: always()
60
+ id: emoji_status
61
+ run: |
62
+ function set-emoji-output {
63
+ if [ "$2" == "success" ];
64
+ then echo "$1=:github-check-mark:" >> $GITHUB_OUTPUT;
65
+ else echo "$1=:github-changes-requested:" >> $GITHUB_OUTPUT;
66
+ fi
67
+ }
68
+ set-emoji-output status ${{ steps.build_and_release.outcome }}
69
+ - name: Slack notification
70
+ if: always()
71
+ uses: rtCamp/action-slack-notify@v2
72
+ env:
73
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASES }}
74
+ SLACK_ICON_EMOJI: ":books:"
75
+ SLACK_USERNAME: Release of LightlyTrain Docs ${{steps.checkout_latest_release_tag.outputs.tag_name}}
76
+ SLACK_COLOR: ${{ steps.build_and_release.outcome }}
77
+ SLACK_FOOTER: ""
78
+ SLACK_MESSAGE: |
79
+ Build status: ${{steps.emoji_status.outputs.status}}
80
+ https://docs.lightly.ai/train/stable/
@@ -0,0 +1,76 @@
1
+ name: Test Unit
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ workflow_dispatch:
9
+
10
+ env:
11
+ # Virtual environment path used by uv and other tools.
12
+ # We create a new environment for each job to avoid conflicts.
13
+ # For more information, see: https://github.com/lightly-ai/lightly-train/.github/workflows/README.md
14
+ VIRTUAL_ENV: ${{ github.workspace }}/.venv
15
+
16
+ concurrency:
17
+ group: ${{ github.workflow }}-${{ github.ref }}
18
+ cancel-in-progress: true
19
+
20
+ jobs:
21
+ detect-code-changes:
22
+ name: Detect Code Changes
23
+ runs-on: docker-cpu
24
+ outputs:
25
+ run-tests: ${{ steps.filter.outputs.run-tests }}
26
+ steps:
27
+ - uses: actions/checkout@v4
28
+ - uses: dorny/paths-filter@v3
29
+ id: filter
30
+ with:
31
+ list-files: shell
32
+ filters: |
33
+ run-tests:
34
+ - '!docs/**'
35
+ - '!docker/**'
36
+ - '!.github/**'
37
+ - '.github/workflows/test_unit.yml'
38
+ test-unit:
39
+ name: Test Unit
40
+ needs: detect-code-changes
41
+ if: needs.detect-code-changes.outputs.run-tests == 'true'
42
+ runs-on: docker-gpu
43
+ strategy:
44
+ matrix:
45
+ python: ["3.8", "3.11"]
46
+ steps:
47
+ - name: Checkout Code
48
+ uses: actions/checkout@v4
49
+ - name: Set Up uv
50
+ uses: astral-sh/setup-uv@v3
51
+ id: setup-uv
52
+ with:
53
+ # For more information about the settings, see:
54
+ # https://github.com/lightly-ai/lightly-train/.github/workflows/README.md
55
+ version: 0.2.25
56
+ cache-local-path: /tmp/setup-uv-cache
57
+ prune-cache: false
58
+ - name: Set Up Python
59
+ uses: actions/setup-python@v5
60
+ with:
61
+ python-version: ${{ matrix.python }}
62
+ - name: Set Up FFmpeg
63
+ uses: FedericoCarboni/setup-ffmpeg@v3
64
+ with:
65
+ ffmpeg-version: 4.3.1
66
+ - name: Set Up Environment
67
+ # For more information about the environment setup, see:
68
+ # https://github.com/lightly-ai/lightly-train/.github/workflows/README.md
69
+ run: |
70
+ rm -rf ${VIRTUAL_ENV} # Make sure the venv is clean
71
+ uv venv ${VIRTUAL_ENV} --python ${{ matrix.python }} # Create the venv
72
+ echo "${VIRTUAL_ENV}/bin" >> $GITHUB_PATH # Add the venv to the PATH
73
+ make install-pinned-${{ matrix.python }} # Install the dependencies
74
+ - name: Run Pytest
75
+ run: |
76
+ make test-ci
@@ -1,11 +1,11 @@
1
1
  # Maintaining LightlyTrain
2
2
 
3
- This document is intended for maintainers of LightlyTrain. If you would like to
3
+ This document is intended for maintainers of Lightly**Train**. If you would like to
4
4
  contribute, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) document.
5
5
 
6
6
  ## Release
7
7
 
8
- Follow these steps to release a new version of LightlyTrain:
8
+ Follow these steps to release a new version of Lightly**Train**:
9
9
 
10
10
  1. Bump the version in `lightly_train/__init__.py`. We use [Semantic Versioning](https://semver.org/). Note that we are still on major version 0 and therefore minor version
11
11
  bumps are considered breaking changes.
@@ -15,5 +15,5 @@ Follow these steps to release a new version of LightlyTrain:
15
15
  1. To release on DockerHub, run the [DockerHub Release action](https://github.com/lightly-ai/lightly-train/actions/workflows/release_dockerhub.yml) from the branch with the new
16
16
  version tag.
17
17
  1. If the README was updated, make sure to copy the information to the DockerHub
18
- description for LightlyTrain: https://hub.docker.com/r/lightly/ (you might have to ask
18
+ description for Lightly**Train**: https://hub.docker.com/r/lightly/ (you might have to ask
19
19
  someone who is a member of the Lightly DockerHub organization to do this for you).
@@ -39,11 +39,11 @@ static-checks: format-check type-check
39
39
  # Files to format with mdformat.
40
40
  # This is needed to avoid formatting files in .venv. The mdformat command has an
41
41
  # --exclude option but only on Python 3.13+.
42
- MDFORMAT_FILES=.github docker docs src tests *.md
42
+ MDFORMAT_FILES := .github docker docs src tests *.md
43
43
 
44
44
  # run formatter
45
45
  .PHONY: format
46
- format:
46
+ format: add-header
47
47
  # Format code
48
48
  ruff format .
49
49
  # Fix linting issues and sort imports
@@ -107,26 +107,26 @@ reset-venv:
107
107
  # Set EDITABLE to -e to install the package in editable mode outside of CI. This is
108
108
  # useful for local development.
109
109
  ifdef CI
110
- EDITABLE=
110
+ EDITABLE :=
111
111
  else
112
- EDITABLE=-e
112
+ EDITABLE := -e
113
113
  endif
114
114
 
115
115
  # SuperGradients is not compatible with Python>=3.10. It is also not easy to install
116
116
  # on MacOS. Therefore we exclude it from the default extras.
117
- EXTRAS = [dev,tensorboard,timm,ultralytics,wandb]
117
+ EXTRAS := [dev,tensorboard,timm,ultralytics,wandb]
118
118
  # Exclude ultralytics from docker extras as it has an AGPL license and we should not
119
119
  # distribute it with the docker image.
120
- DOCKER_EXTRAS = --extra tensorboard --extra timm --extra wandb
120
+ DOCKER_EXTRAS := --extra tensorboard --extra timm --extra wandb
121
121
 
122
122
  # Date until which dependencies installed with --exclude-newer must have been released.
123
123
  # Dependencies released after this date are ignored.
124
- EXCLUDE_NEWER_DATE="2024-08-28"
124
+ EXCLUDE_NEWER_DATE := "2024-08-28"
125
125
  # Pinned versions for Torch and TorchVision to avoid issues with the CUDA version on the CI machine.
126
126
  # These versions are compatible with CUDA 11.4 and Python 3.8. They are the latest versions
127
127
  # available before 2024-08-28.
128
- PINNED_TORCH_VERSION="2.4.0+cu118"
129
- PINNED_TORCHVISION_VERSION="0.19.0+cu118"
128
+ PINNED_TORCH_VERSION := "2.4.0+cu118"
129
+ PINNED_TORCHVISION_VERSION := "0.19.0+cu118"
130
130
 
131
131
  # Install ffmpeg on Ubuntu.
132
132
  . PHONY: install-ffmpeg-ubuntu
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lightly_train
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Train models with self-supervised learning in a single command
5
5
  Author: Lightly Team
6
6
  License: AGPL-3.0
@@ -49,17 +49,17 @@ Requires-Dist: wandb>=0.12.10; extra == "wandb"
49
49
 
50
50
  ## Why LightlyTrain
51
51
 
52
- LightlyTrain uses self-supervised learning (SSL) to train models on large datasets
52
+ Lightly**Train** uses self-supervised learning (SSL) to train models on large datasets
53
53
  without the need for labels. It provides simple Python, Command Line, and Docker
54
54
  interfaces to train models with popular SSL methods such as SimCLR or DINO. The trained
55
55
  models are ideal starting points for fine-tuning on downstream tasks such as image
56
56
  classification, object detection, and segmentation or for generating image embeddings.
57
- Models trained with LightlyTrain result in improved performance, faster convergence, and
57
+ Models trained with Lightly**Train** result in improved performance, faster convergence, and
58
58
  better generalization compared to models trained without SSL. Image embeddings created
59
- with LightlyTrain capture more relevant information than their supervised counterparts
59
+ with Lightly**Train** capture more relevant information than their supervised counterparts
60
60
  and seamlessly extend to new classes due to the unsupervised nature of SSL.
61
61
 
62
- Lightly is the expert in SSL for computer vision and developed LightlyTrain to simplify
62
+ Lightly is the expert in SSL for computer vision and developed Lightly**Train** to simplify
63
63
  model training for any task and dataset.
64
64
 
65
65
  ## Features
@@ -77,7 +77,7 @@ model training for any task and dataset.
77
77
 
78
78
  ## License
79
79
 
80
- LightlyTrain is available under an AGPL-3.0 and a commercial license. Please contact us
80
+ Lightly**Train** is available under an AGPL-3.0 and a commercial license. Please contact us
81
81
  at info@lightly.ai for more information.
82
82
 
83
83
  ## Contact
@@ -4,17 +4,17 @@
4
4
 
5
5
  ## Why LightlyTrain
6
6
 
7
- LightlyTrain uses self-supervised learning (SSL) to train models on large datasets
7
+ Lightly**Train** uses self-supervised learning (SSL) to train models on large datasets
8
8
  without the need for labels. It provides simple Python, Command Line, and Docker
9
9
  interfaces to train models with popular SSL methods such as SimCLR or DINO. The trained
10
10
  models are ideal starting points for fine-tuning on downstream tasks such as image
11
11
  classification, object detection, and segmentation or for generating image embeddings.
12
- Models trained with LightlyTrain result in improved performance, faster convergence, and
12
+ Models trained with Lightly**Train** result in improved performance, faster convergence, and
13
13
  better generalization compared to models trained without SSL. Image embeddings created
14
- with LightlyTrain capture more relevant information than their supervised counterparts
14
+ with Lightly**Train** capture more relevant information than their supervised counterparts
15
15
  and seamlessly extend to new classes due to the unsupervised nature of SSL.
16
16
 
17
- Lightly is the expert in SSL for computer vision and developed LightlyTrain to simplify
17
+ Lightly is the expert in SSL for computer vision and developed Lightly**Train** to simplify
18
18
  model training for any task and dataset.
19
19
 
20
20
  ## Features
@@ -32,7 +32,7 @@ model training for any task and dataset.
32
32
 
33
33
  ## License
34
34
 
35
- LightlyTrain is available under an AGPL-3.0 and a commercial license. Please contact us
35
+ Lightly**Train** is available under an AGPL-3.0 and a commercial license. Please contact us
36
36
  at info@lightly.ai for more information.
37
37
 
38
38
  ## Contact
@@ -1,11 +1,11 @@
1
1
  TAG ?= $(shell git rev-parse HEAD)
2
2
  IMAGE ?= train
3
- DOCKER_BUILDKIT=1
4
- CONTAINER_REGISTRY=eu.gcr.io/boris-250909
3
+ DOCKER_BUILDKIT := 1
4
+ CONTAINER_REGISTRY := eu.gcr.io/boris-250909
5
5
 
6
- VERSION = $(shell grep '__version__' ../src/lightly_train/__init__.py | sed -E 's/[^0-9.]//g')
7
- VERSION_X=$(shell echo $(VERSION) | cut -d. -f1)
8
- VERSION_XY=$(shell echo $(VERSION) | cut -d. -f1-2)
6
+ VERSION := $(shell grep '__version__' ../src/lightly_train/__init__.py | sed -E 's/[^0-9.]//g')
7
+ VERSION_X := $(shell echo $(VERSION) | cut -d. -f1)
8
+ VERSION_XY := $(shell echo $(VERSION) | cut -d. -f1-2)
9
9
 
10
10
  # print all versions
11
11
  .PHONY: print-versions
@@ -52,8 +52,8 @@ main-deploy-amd64-cuda:
52
52
  --output=$(OUTPUT) \
53
53
  ..
54
54
 
55
-
56
- DATE=$(shell date +'%Y-%m-%d-%H-%M-%S')
55
+ # DATE variable must be assigned with `:=` to avoid re-evaluation.
56
+ DATE := $(shell date +'%Y-%m-%d-%H-%M-%S')
57
57
  LIGHTLY_TRAIN_OUT ?= $(PWD)/../out/docker/$(DATE)
58
58
  LIGHTLY_TRAIN_DATA ?= $(PWD)/../lightly_train_docker_test_data
59
59
 
@@ -1,27 +1,31 @@
1
1
  ### Documentation
2
2
 
3
3
  VERSION ?= $(shell grep '__version__' ../src/lightly_train/__init__.py | sed -E 's/[^0-9.]//g')
4
- BUILD_DIR = build
4
+ BUILD_DIR := build
5
5
  # The build directory for the current version. We create a new directory for each
6
6
  # version to simplify hosting the documentation for multiple versions. This follows
7
7
  # the pattern used by PyTorch: https://pytorch.org/docs/versions.html
8
- BUILD_VERSION_DIR = ${BUILD_DIR}/${VERSION}
9
- BUILD_STABLE_DIR = ${BUILD_DIR}/stable
10
- SOURCE_DIR = source
8
+ BUILD_VERSION_DIR := ${BUILD_DIR}/${VERSION}
9
+ BUILD_STABLE_DIR := ${BUILD_DIR}/stable
10
+ SOURCE_DIR := source
11
11
 
12
12
 
13
13
  # Build docs for the current version.
14
14
  .PHONY: docs
15
15
  docs:
16
+ @echo "📚 Building v${VERSION} documentation..."
16
17
  sphinx-build --builder html ${SOURCE_DIR} ${BUILD_VERSION_DIR}
17
18
  python build.py --build-dir ${BUILD_DIR}
19
+ @echo "✅ Documentation built successfully!"
18
20
 
19
21
  # Build docs for the stable version. Assumes that the current version is the stable
20
22
  # version.
21
23
  .PHONY: docs-stable
22
24
  docs-stable:
25
+ @echo "🗿 Building stable documentation..."
23
26
  sphinx-build --builder html ${SOURCE_DIR} ${BUILD_STABLE_DIR}
24
27
  python build.py --build-dir ${BUILD_DIR}
28
+ @echo "✅ Documentation built successfully!"
25
29
 
26
30
  # Serve the documentation on localhost.
27
31
  .PHONY: serve
@@ -3,9 +3,9 @@
3
3
  color: var(--color-brand-primary);
4
4
  font-size: 1rem;
5
5
  text-align: left;
6
- margin: var(--sidebar-item-spacing-vertical) 0;
6
+ padding: var(--sidebar-item-spacing-vertical) var(--sidebar-item-spacing-horizontal);
7
7
  }
8
8
 
9
9
  .sidebar-version:visited {
10
10
  color: var(--color-brand-primary);
11
- }
11
+ }
@@ -1,4 +1,4 @@
1
- <svg width="189" height="48" viewBox="0 0 189 48" fill="none" xmlns="http://www.w3.org/2000/svg">
1
+ <svg width="100%" height="auto" viewBox="0 0 189 48" fill="none" xmlns="http://www.w3.org/2000/svg">
2
2
  <path fill-rule="evenodd" clip-rule="evenodd" d="M0 5.64209H5.01493V42.157H41.6866V47.1719H0V5.64209Z" fill="#A72264"/>
3
3
  <path fill-rule="evenodd" clip-rule="evenodd" d="M10.9701 0H15.985V31.0299H30.7164V36.0448H10.9701V0Z" fill="#A72264"/>
4
4
  <path fill-rule="evenodd" clip-rule="evenodd" d="M42 36.0449H36.9851V10.3434H22.2537V5.3285H42V36.0449Z" fill="#A72264"/>
@@ -0,0 +1 @@
1
+ <a class="sidebar-version" href="../versions.html">{{ version }} ▼</a>
@@ -0,0 +1,62 @@
1
+ (docker)=
2
+
3
+ # Docker
4
+
5
+ Lightly**Train** is available as a Docker image on [Docker Hub](https://hub.docker.com/r/lightly/train)
6
+ for containerized deployment.
7
+
8
+ (docker-installation)=
9
+
10
+ ## Installation
11
+
12
+ Install Docker with NVIDIA GPU support ([docs](https://docs.lightly.ai/docs/lightly-worker-installation-guide#install-docker-optionally-with-gpu-support)).
13
+ Then, pull the latest version of the Lightly**Train** Docker image from Docker Hub:
14
+
15
+ ```bash
16
+ docker pull lightly/train:latest
17
+ ```
18
+
19
+ You can verify that the image is working correctly by running the following command:
20
+
21
+ ```bash
22
+ docker run --rm --gpus=all lightly/train:latest lightly-train --help
23
+ ```
24
+
25
+ This should print the Lightly**Train** help message.
26
+
27
+ (docker-usage)=
28
+
29
+ ## Usage
30
+
31
+ Start a Lightly**Train** Docker container in interactive mode:
32
+
33
+ ```bash
34
+ docker run -it --rm --gpus=all --shm-size=4gb --user $(id -u):$(id -g) -v /my_output_dir:/out -v /my_data_dir:/data lightly/train:latest
35
+ ```
36
+
37
+ Flags:
38
+
39
+ - `-it`: Starts the container in interactive mode.
40
+ - `--rm`: Removes the container after it has been stopped.
41
+ - `--gpus=all`: Enables GPU support.
42
+ - `--shm-size=4gb`: Sets the shared memory size to 4 GB. Increase this for large datasets.
43
+ - `--user $(id -u):$(id -g)`: Run the container with the same user as the host. This
44
+ makes sure that all files created by the container (checkpoints, logs, etc.) have
45
+ the same permissions as the user running the container.
46
+ - `-v /my_output_dir:/out`: Mounts the host directory `/my_output_dir` to the container
47
+ directory `/out`. All files created by the container (checkpoints, logs, etc.) will
48
+ be saved in this directory.
49
+ - `-v /my_data_dir:/data`: Mounts the host directory `/my_data_dir` to the container
50
+ directory `/data`. This directory must contain your training data. See the
51
+ [Data](#train-data) docs for more information on how to structure your data.
52
+
53
+ Once the container is running, you can run Lightly**Train** commands inside the container
54
+ as if you had installed it locally. The only difference is that paths must be specified
55
+ relative to the mounted directories `/out` and `/data`. For example, to train a model,
56
+ run the following command inside the container:
57
+
58
+ ````{tab} Command Line
59
+ ```bash
60
+ lightly-train train out="/out/my_experiment" data="/data" model="torchvision/resnet50" method="dino"
61
+ ```
62
+ ````
@@ -0,0 +1,100 @@
1
+ (embed)=
2
+
3
+ # Embed
4
+
5
+ The `embed` command is used to embed images with a [training checkpoint](#train-output).
6
+ An example command looks like this:
7
+
8
+ ````{tab} Python
9
+ ```python
10
+ import lightly_train
11
+
12
+ lightly_train.train(
13
+ out="out/my_experiment",
14
+ data="my_data_dir",
15
+ model="torchvision/resnet50",
16
+ method="dino",
17
+ )
18
+
19
+ lightly_train.embed(
20
+ out="my_embeddings.pth",
21
+ data="my_data_dir",
22
+ checkpoint="out/my_experiment/checkpoints/last.ckpt",
23
+ format="torch",
24
+ )
25
+ ````
26
+
27
+ ````{tab} Command Line
28
+ ```bash
29
+ lightly-train train out="out/my_experiment" data="my_data_dir" model="torchvision/resnet50" method="dino"
30
+ lightly-train embed out=my_embeddings.pth data=my_data_dir checkpoint=out/my_experiment/checkpoints/last.ckpt format=torch
31
+ ````
32
+
33
+ The above code example trains a model and uses the last training checkpoint to generate
34
+ image embeddings from the images in `"my_data_dir"`.
35
+
36
+ ```{tip}
37
+ See {meth}`lightly_train.embed` for a complete list of arguments.
38
+ ```
39
+
40
+ ## Out
41
+
42
+ The `out` argument specifies the output file where the embeddings and corresponding
43
+ image filenames are saved. Image filenames are always relative to the `data` directory.
44
+ See [format](#embedding-format) for details on how the embeddings are saved.
45
+
46
+ The embedding dimension is determined by the model used for training. If the `embed_dim`
47
+ argument was set during training, the embeddings will have this dimension, otherwise
48
+ the default embedding dimension of the model is used.
49
+
50
+ ## Data
51
+
52
+ The `data` argument specifies the directory with images to embed. The same image formats
53
+ as in the [training command](#train-data) are supported.
54
+
55
+ ## Checkpoint
56
+
57
+ The `checkpoint` argument specifies the Lightly**Train** checkpoint to use for embedding.
58
+ This is the checkpoint saved to `out/my_experiment/checkpoints/last.ckpt` after
59
+ training.
60
+
61
+ (embedding-format)=
62
+
63
+ ## Format
64
+
65
+ The `format` argument specifies the format in which the embeddings are saved. The
66
+ following formats are supported:
67
+
68
+ - `csv`: Embeddings are saved as a CSV file with one row per image. The first column
69
+ contains the filename and the remaining columns contain the embedding values.
70
+ An example CSV file looks like this:
71
+ ```text
72
+ filename,embedding_0,embedding_1,embedding_2
73
+ image1.jpg,0.1,0.2,0.3
74
+ image2.jpg,0.4,0.5,0.6
75
+ ```
76
+ - `lightly_csv`: Embeddings are saved as a CSV file with one row per image. The CSV file
77
+ is compatible with the [Lightly Worker](https://docs.lightly.ai/docs/custom-embeddings).
78
+ The labels column is always set to 0. An example CSV file looks like this:
79
+ ```text
80
+ filenames,embedding_0,embedding_1,embedding_2,labels
81
+ image1.jpg,0.1,0.2,0.3,0
82
+ image2.jpg,0.4,0.5,0.6,0
83
+ ```
84
+ - `torch`: The embeddings are saved as dictionary in a torch file with the following
85
+ structure:
86
+ ```python
87
+ {
88
+ "embeddings": torch.Tensor, # Embeddings with shape (N, D) where N is the number
89
+ # of images and D is the embedding dimension.
90
+ "filenames": list[str], # List of N filenames corresponding to the embeddings.
91
+ }
92
+ ```
93
+ The embeddings can be loaded with:
94
+ ```python
95
+ import torch
96
+
97
+ embeddings = torch.load("my_embeddings.pth", weights_only=True)
98
+ embeddings["embeddings"] # Embeddings
99
+ embeddings["filenames"] # Image filenames
100
+ ```