mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
+1
-1
@@ -66,7 +66,7 @@ def attention_forward(self, x, resolution, shared_rel_pos_bias: Optional[torch.T
|
||||
"""
|
||||
Modification of timm.models.beit.py: Attention.forward to support arbitrary window sizes.
|
||||
"""
|
||||
B, N, _C = x.shape
|
||||
B, N, C = x.shape
|
||||
|
||||
qkv_bias = torch.cat((self.q_bias, self.k_bias, self.v_bias)) if self.q_bias is not None else None
|
||||
qkv = F.linear(input=x, weight=self.qkv.weight, bias=qkv_bias)
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ def forward_default(pretrained, x, function_name="forward_features"):
|
||||
|
||||
|
||||
def forward_adapted_unflatten(pretrained, x, function_name="forward_features"):
|
||||
_b, _c, h, w = x.shape
|
||||
b, c, h, w = x.shape
|
||||
|
||||
exec(f"glob = pretrained.model.{function_name}(x)")
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ def _resize_pos_embed(self, posemb, gs_h, gs_w):
|
||||
|
||||
|
||||
def forward_flex(self, x):
|
||||
_b, _c, h, w = x.shape
|
||||
b, c, h, w = x.shape
|
||||
|
||||
pos_embed = self._resize_pos_embed(
|
||||
self.pos_embed, h // self.patch_size[1], w // self.patch_size[0]
|
||||
|
||||
@@ -5,6 +5,10 @@ from .backbones.beit import (
|
||||
_make_pretrained_beitl16_512,
|
||||
_make_pretrained_beitl16_384,
|
||||
_make_pretrained_beitb16_384,
|
||||
forward_beit,
|
||||
)
|
||||
from .backbones.swin_common import (
|
||||
forward_swin,
|
||||
)
|
||||
from .backbones.swin2 import (
|
||||
_make_pretrained_swin2l24_384,
|
||||
@@ -16,11 +20,13 @@ from .backbones.swin import (
|
||||
)
|
||||
from .backbones.levit import (
|
||||
_make_pretrained_levit_384,
|
||||
forward_levit,
|
||||
)
|
||||
from .backbones.vit import (
|
||||
_make_pretrained_vitb_rn50_384,
|
||||
_make_pretrained_vitl16_384,
|
||||
_make_pretrained_vitb16_384,
|
||||
forward_vit,
|
||||
)
|
||||
|
||||
def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None,
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import torch
|
||||
import torch.nn as nn
|
||||
|
||||
from .base_model import BaseModel
|
||||
from .blocks import FeatureFusionBlock_custom, Interpolate, _make_encoder
|
||||
from .blocks import FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder
|
||||
|
||||
|
||||
class MidasNet_small(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user