Upload model
Browse files- modeling_solider.py +8 -12
modeling_solider.py
CHANGED
@@ -27,6 +27,8 @@ from itertools import repeat
|
|
27 |
import collections.abc
|
28 |
|
29 |
from .configuration_solider import SOLIDERConfig, BACKBONE_NAME2WIDTH
|
|
|
|
|
30 |
def _ntuple(n):
|
31 |
def parse(x):
|
32 |
if isinstance(x, collections.abc.Iterable):
|
@@ -1628,7 +1630,6 @@ def build_solider(cfg: dict) -> SwinTransformer:
|
|
1628 |
# }
|
1629 |
|
1630 |
|
1631 |
-
|
1632 |
SOLIDER_BASE_MODEL_CONFIG_PARAMETERS = {
|
1633 |
"pretrain_img_size": [224, 224],
|
1634 |
"in_channels": 3,
|
@@ -1771,14 +1772,12 @@ class SOLIDERModel(PreTrainedModel):
|
|
1771 |
self.solider_name = config.name
|
1772 |
self.vision_width = BACKBONE_NAME2WIDTH[self.solider_name]
|
1773 |
self.hidden_size = self.vision_width
|
1774 |
-
|
1775 |
self.config = config
|
1776 |
# self.init_weights()
|
1777 |
|
1778 |
-
def forward(self, x
|
1779 |
-
|
1780 |
-
semantic_weight = self.config.semantic_weight
|
1781 |
-
return self.solider(x, semantic_weight)
|
1782 |
|
1783 |
|
1784 |
# NOTE: Currently not used!
|
@@ -1791,7 +1790,7 @@ class SoliderEncoder(SwinTransformer):
|
|
1791 |
|
1792 |
@classmethod
|
1793 |
def from_config(cls, cfg, from_pretrained=None):
|
1794 |
-
|
1795 |
name = cfg.get("name", "swin_small_patch4_window7_224")
|
1796 |
img_size = cfg.get("img_size", [384, 128])
|
1797 |
drop_path_rate = cfg.get("drop_path_rate", 0.1)
|
@@ -1840,8 +1839,5 @@ class SoliderEncoder(SwinTransformer):
|
|
1840 |
model.config = cfg
|
1841 |
return model
|
1842 |
|
1843 |
-
def forward_features(self, x
|
1844 |
-
|
1845 |
-
semantic_weight = self.config.semantic_weight
|
1846 |
-
return SwinTransformer.forward(self, x, semantic_weight)
|
1847 |
-
|
|
|
27 |
import collections.abc
|
28 |
|
29 |
from .configuration_solider import SOLIDERConfig, BACKBONE_NAME2WIDTH
|
30 |
+
|
31 |
+
|
32 |
def _ntuple(n):
|
33 |
def parse(x):
|
34 |
if isinstance(x, collections.abc.Iterable):
|
|
|
1630 |
# }
|
1631 |
|
1632 |
|
|
|
1633 |
SOLIDER_BASE_MODEL_CONFIG_PARAMETERS = {
|
1634 |
"pretrain_img_size": [224, 224],
|
1635 |
"in_channels": 3,
|
|
|
1772 |
self.solider_name = config.name
|
1773 |
self.vision_width = BACKBONE_NAME2WIDTH[self.solider_name]
|
1774 |
self.hidden_size = self.vision_width
|
1775 |
+
|
1776 |
self.config = config
|
1777 |
# self.init_weights()
|
1778 |
|
1779 |
+
def forward(self, x):
|
1780 |
+
return self.solider(x, None)
|
|
|
|
|
1781 |
|
1782 |
|
1783 |
# NOTE: Currently not used!
|
|
|
1790 |
|
1791 |
@classmethod
|
1792 |
def from_config(cls, cfg, from_pretrained=None):
|
1793 |
+
|
1794 |
name = cfg.get("name", "swin_small_patch4_window7_224")
|
1795 |
img_size = cfg.get("img_size", [384, 128])
|
1796 |
drop_path_rate = cfg.get("drop_path_rate", 0.1)
|
|
|
1839 |
model.config = cfg
|
1840 |
return model
|
1841 |
|
1842 |
+
def forward_features(self, x):
|
1843 |
+
return SwinTransformer.forward(self, x, None)
|
|
|
|
|
|