Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
shijianjian committed Sep 4, 2024
1 parent aac4ad3 commit d6268f0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def build_2d_sincos_pos_emb(

class TransformerEncoder(nn.Module):
def __init__(self, encoder_layer: nn.Module, num_layers: int) -> None:
super(TransformerEncoder, self).__init__()
super().__init__()
self.layers = nn.ModuleList([copy.deepcopy(encoder_layer) for _ in range(num_layers)])
self.num_layers = num_layers

Expand Down
5 changes: 2 additions & 3 deletions kornia/contrib/models/rt_detr/architecture/resnet_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

from collections import OrderedDict
from typing import List, Tuple

from torch import nn

Expand Down Expand Up @@ -104,7 +103,7 @@ def __init__(self, n_blocks: list[int], block: type[BasicBlockD | BottleneckD])
@staticmethod
def make_stage(
in_channels: int, out_channels: int, stride: int, n_blocks: int, block: type[BasicBlockD | BottleneckD]
) -> Tuple[Module, int]:
) -> tuple[Module, int]:
stage = Block(
nn.Sequential(
block(in_channels, out_channels, stride, False),
Expand All @@ -113,7 +112,7 @@ def make_stage(
)
return stage, out_channels * block.expansion

def forward(self, x: Tensor) -> List[Tensor]:
def forward(self, x: Tensor) -> list[Tensor]:
x = self.conv1(x)
res2 = self.res_layers[0](x)
res3 = self.res_layers[1](res2)
Expand Down
4 changes: 2 additions & 2 deletions kornia/contrib/models/rt_detr/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
from dataclasses import dataclass
from enum import Enum
from typing import Dict, Optional
from typing import Optional

import torch

Expand Down Expand Up @@ -194,7 +194,7 @@ def map_name(old_name: str) -> str:

return new_name

def _state_dict_proc(state_dict: Dict[str, Tensor]) -> Dict[str, Tensor]:
def _state_dict_proc(state_dict: dict[str, Tensor]) -> dict[str, Tensor]:
state_dict = state_dict["ema"]["module"] # type:ignore
new_state_dict = {}

Expand Down

0 comments on commit d6268f0

Please sign in to comment.