Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions docs/source/getting_started/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ There are three ways how you can customize augmentations in Lightly\ **SSL**:
Previewing Augmentations
^^^^^^^^^^^^^^^^^^^^^^^^

.. note::
This section is outdated and still uses the old collate functions which are deprecated
since v1.4.0. We will update this section soon.

It often can be very useful to understand how the image augmentations we pick affect
the input dataset. We provide a few helper methods that make it very easy to
preview augmentations using Lightly\ **SSL**.
Expand All @@ -183,7 +179,7 @@ well as their augmentations next to them.
:align: center
:alt: SimCLR augmentations example

Example augmentations of the `SimCLRCollateFunction` function on images
Example augmentations of the `SimCLRTransform` transform on images
from the clothing dataset.

The images seem rather blurry! However, we don't want our model to ignore small
Expand All @@ -194,17 +190,17 @@ details. Let's disable Gaussian Blur and check again:
:align: center
:alt: SimCLR augmentations example

Example augmentations of the `SimCLRCollateFunction` function on images
Example augmentations of the `SimCLRTransform` transform on images
from the clothing dataset.

We can also repeat the experiment for the `DINOCollateFunction` to see what
We can also repeat the experiment for the `DINOTransform` to see what
our DINO model would see during training.

.. figure:: images/dino_augmentations.jpg
:align: center
:alt: DINO augmentations example

Example augmentations of the `DINOCollateFunction` function on images
Example augmentations of the `DINOTransform` transform on images
from the clothing dataset.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
# load the first two images using pillow
input_images = [Image.open(fname) for fname in fnames[:2]]

# create our colalte function
collate_fn_simclr = lightly.data.SimCLRCollateFunction()
# create our transform
transform_simclr = lightly.transforms.SimCLRTransform()

# plot the images
fig = lightly.utils.debug.plot_augmented_images(input_images, collate_fn_simclr)
fig = lightly.utils.debug.plot_augmented_images(input_images, transform_simclr)

# let's disable blur
collate_fn_simclr_no_blur = lightly.data.SimCLRCollateFunction()
fig = lightly.utils.debug.plot_augmented_images(input_images, collate_fn_simclr_no_blur)
transform_simclr_no_blur = lightly.transforms.SimCLRTransform(gaussian_blur=0.0)
fig = lightly.utils.debug.plot_augmented_images(input_images, transform_simclr_no_blur)

# we can also use the DINO collate function instead
collate_fn_dino = lightly.data.DINOCollateFunction()
fig = lightly.utils.debug.plot_augmented_images(input_images, collate_fn_dino)
# we can also use the DINO transform instead
transform_dino = lightly.transforms.DINOTransform()
fig = lightly.utils.debug.plot_augmented_images(input_images, transform_dino)
10 changes: 2 additions & 8 deletions docs/source/lightly.data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ lightly.data
--------------

.. note::
``IJEPAMaskCollator`` used to live in ``lightly.data.collate``. That import path
still works but warns, and is removed in v1.7.0. Use
``from lightly.data import IJEPAMaskCollator``.
``IJEPAMaskCollator`` used to live in ``lightly.data.collate``, which has been
removed. Use ``from lightly.data import IJEPAMaskCollator``.

.. autoclass:: lightly.data.ijepa_collate.IJEPAMaskCollator
:members:
:special-members: __call__

.collate:
---------
.. automodule:: lightly.data.collate
:members:
3 changes: 0 additions & 3 deletions docs/source/lightly.loss.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ lightly.loss
.. autoclass:: lightly.loss.swav_loss.SwaVLoss
:members:

.. autoclass:: lightly.loss.sym_neg_cos_sim_loss.SymNegCosineSimilarityLoss
:members:

.. autoclass:: lightly.loss.tico_loss.TiCoLoss
:members:

Expand Down
3 changes: 1 addition & 2 deletions lightly/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
- **data**:

The lightly.data module provides a dataset wrapper and collate functions. The
collate functions are in charge of the data augmentations which are crucial for
self-supervised learning.
collate functions combine the views produced by a transform into a batch.

- **loss**:

Expand Down
7 changes: 1 addition & 6 deletions lightly/cli/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ optimizer:
lr: 1. # Learning rate of the optimizer.
weight_decay: 0.00001 # L2 penalty.

# collate namespace: Passed to lightly.data.ImageCollateFunction.
# collate namespace: Passed to lightly.transforms.SimCLRTransform.
collate:
input_size: 64 # Size of the input images in pixels.
cj_prob: 0.8 # Probability that color jitter is applied.
Expand All @@ -44,9 +44,6 @@ collate:
random_gray_scale: 0.2 # Probability of converting image to gray scale.
gaussian_blur: 0.5 # Probability of Gaussian blur.
sigmas: [0.2, 2] # Sigmas of Gaussian blur
kernel_size: null # Will be deprecated in favor of `sigmas` argument. If set, the old behavior
# applies and `sigmas` is ignored. Used to calculate sigma of gaussian blur
# with kernel_size * input_size.
vf_prob: 0.0 # Probability that vertical flip is applied.
hf_prob: 0.5 # Probability that horizontal flip is applied.
rr_prob: 0.0 # Probability that random rotation is applied.
Expand All @@ -71,8 +68,6 @@ trainer:
max_epochs: 100 # Number of epochs to train for.
precision: 32 # If set to 16, will use half-precision.
enable_model_summary: True # Whether to enable model summarisation.
weights_summary: # [deprecated] Use enable_model_summary
# and summary_callback.max_depth.

# checkpoint_callback namespace: Modify the checkpoint callback
checkpoint_callback:
Expand Down
10 changes: 5 additions & 5 deletions lightly/cli/train_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
load_from_state_dict,
load_state_dict_from_url,
)
from lightly.data import ImageCollateFunction, LightlyDataset
from lightly.data import LightlyDataset, MultiViewCollate
from lightly.embedding import SelfSupervisedEmbedding
from lightly.loss import NTXentLoss
from lightly.models import ResNetGenerator
from lightly.models.batchnorm import get_norm_layer
from lightly.transforms import SimCLRTransform
from lightly.utils.hipify import bcolors


Expand Down Expand Up @@ -108,13 +109,12 @@ def _train_cli(cfg, is_cli_call=True):
criterion = NTXentLoss(**cfg["criterion"])
optimizer = torch.optim.SGD(model.parameters(), **cfg["optimizer"])

dataset = LightlyDataset(input_dir)
dataset = LightlyDataset(input_dir, transform=SimCLRTransform(**cfg["collate"]))

cfg["loader"]["batch_size"] = min(cfg["loader"]["batch_size"], len(dataset))

collate_fn = ImageCollateFunction(**cfg["collate"])
dataloader = torch.utils.data.DataLoader(
dataset, **cfg["loader"], collate_fn=collate_fn
dataset, **cfg["loader"], collate_fn=MultiViewCollate()
)

encoder = SelfSupervisedEmbedding(model, criterion, optimizer, dataloader)
Expand Down Expand Up @@ -177,7 +177,7 @@ def train_cli(cfg):
>>> lightly-ssl-train input_dir=data/ trainer.max_epochs=10
>>>
>>> # print a full summary of the model
>>> lightly-ssl-train input_dir=data/ trainer.weights_summary=full
>>> lightly-ssl-train input_dir=data/ summary_callback.max_depth=-1

"""
return _train_cli(cfg)
Expand Down
15 changes: 1 addition & 14 deletions lightly/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
UnseekableTimestampError,
VideoError,
)
from lightly.data.collate import (
BaseCollateFunction,
DINOCollateFunction,
ImageCollateFunction,
MAECollateFunction,
MoCoCollateFunction,
MSNCollateFunction,
MultiCropCollateFunction,
PIRLCollateFunction,
SimCLRCollateFunction,
SwaVCollateFunction,
VICRegLCollateFunction,
imagenet_normalize,
)
from lightly.data.dataset import LightlyDataset
from lightly.data.ijepa_collate import IJEPAMaskCollator
from lightly.data.multi_view_collate import MultiViewCollate
Loading
Loading