EfficientFormer
EfficientFormer copied to clipboard
Updated timm imports
According to updates to the timm module after Oct 10, 2022 (available in version >= 0.9):
Yeah, I came across this issue too.
I can confirm that this patch would fix the issue. I independently fixed it myself before I learnt of this PR though, so I include my own .patch file below, including a typographical error I found in a comment.
diff --git a/models/efficientformer.py b/models/efficientformer.py
index a379823..66e0c4e 100644
--- a/models/efficientformer.py
+++ b/models/efficientformer.py
@@ -10,9 +10,9 @@ from typing import Dict
import itertools
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
-from timm.models.layers import DropPath, trunc_normal_
+from timm.models.layers import DropPath, trunc_normal_, to_2tuple
from timm.models.registry import register_model
-from timm.models.layers.helpers import to_2tuple
+# from timm.models.layers.helpers import to_2tuple
EfficientFormer_width = {
'l1': [48, 96, 224, 448],
diff --git a/models/efficientformer_v2.py b/models/efficientformer_v2.py
index 48234a4..1f4fcde 100644
--- a/models/efficientformer_v2.py
+++ b/models/efficientformer_v2.py
@@ -11,9 +11,9 @@ from typing import Dict
import itertools
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
-from timm.models.layers import DropPath, trunc_normal_
+from timm.models.layers import DropPath, trunc_normal_, to_2tuple
from timm.models.registry import register_model
-from timm.models.layers.helpers import to_2tuple
+# from timm.models.layers.helpers import to_2tuple
EfficientFormer_width = {
'L': [40, 80, 192, 384], # 26m 83.3% 6attn
@@ -631,7 +631,7 @@ class EfficientFormerV2(nn.Module):
x = self.patch_embed(x)
x = self.forward_tokens(x)
if self.fork_feat:
- # otuput features of four stages for dense prediction
+ # output features of four stages for dense prediction
return x
# print(x.size())
x = self.norm(x)