Skip to content

Commit

Permalink
fixed import
Browse files Browse the repository at this point in the history
  • Loading branch information
ersi-lightly committed Jan 5, 2024
1 parent f008645 commit c97112e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/pytorch/mae_timm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Note: The model and training settings do not follow the reference settings
# from the paper. The settings are chosen such that the example can easily be
# run on a small dataset with a single GPU.
import sys

import torch
import torchvision
Expand All @@ -14,6 +15,7 @@
from timm.models import vision_transformer
except ImportError:
print("TIMM is not available. Please install in order to run this example.")
sys.exit(1)


class MAE(nn.Module):
Expand Down
5 changes: 2 additions & 3 deletions lightly/models/modules/masked_autoencoder_timm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

Check warning on line 1 in lightly/models/modules/masked_autoencoder_timm.py

View check run for this annotation

Codecov / codecov/patch

lightly/models/modules/masked_autoencoder_timm.py#L1

Added line #L1 was not covered by tests

import math
import sys
from functools import partial
from typing import Callable, Optional, Tuple, Type, Union

Check warning on line 6 in lightly/models/modules/masked_autoencoder_timm.py

View check run for this annotation

Codecov / codecov/patch

lightly/models/modules/masked_autoencoder_timm.py#L3-L6

Added lines #L3 - L6 were not covered by tests

Expand All @@ -9,14 +10,12 @@
except ImportError:
from typing_extensions import Literal

Check warning on line 11 in lightly/models/modules/masked_autoencoder_timm.py

View check run for this annotation

Codecov / codecov/patch

lightly/models/modules/masked_autoencoder_timm.py#L8-L11

Added lines #L8 - L11 were not covered by tests

from timm.layers import LayerType, Mlp, PatchEmbed
from timm.models import vision_transformer

try:
from timm.layers import LayerType, Mlp, PatchEmbed
from timm.models import vision_transformer
except ImportError:
print("TIMM is not available. Please install if you would like to use the MAE.")
sys.exit(1)

Check warning on line 18 in lightly/models/modules/masked_autoencoder_timm.py

View check run for this annotation

Codecov / codecov/patch

lightly/models/modules/masked_autoencoder_timm.py#L13-L18

Added lines #L13 - L18 were not covered by tests

import torch
import torch.nn as nn
Expand Down

0 comments on commit c97112e

Please sign in to comment.