Skip to content

Commit

Permalink
style: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
sokovninn committed Sep 10, 2024
1 parent 2363f8c commit fbd6f37
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from dataclasses import dataclass, field
from typing import Literal

from luxonis_train.utils.config import (
LossModuleConfig,
Expand Down
2 changes: 1 addition & 1 deletion luxonis_train/nodes/backbones/ddrnet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .ddrnet import DDRNet

__all__ = ["DDRNet"]
__all__ = ["DDRNet"]
12 changes: 5 additions & 7 deletions luxonis_train/nodes/backbones/ddrnet/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
Paper: U{https://arxiv.org/pdf/2101.06085.pdf}
@license: U{https://github.com/Deci-AI/super-gradients/blob/master/LICENSE.md}
"""
from abc import ABC
from typing import Dict, Type
from typing import Type

import torch
from torch import Tensor, nn
from torch.nn import functional as F

from luxonis_train.nodes.base_node import BaseNode
from luxonis_train.nodes.blocks import ConvModule


Expand Down Expand Up @@ -371,6 +369,7 @@ def forward(self, x: Tensor, output_height: int, output_width: int) -> Tensor:
"""
return F.interpolate(x, size=[output_height, output_width], mode=self.mode)


class BasicDDRBackBone(nn.Module):
def __init__(
self,
Expand Down Expand Up @@ -505,6 +504,7 @@ def get_backbone_output_number_of_channels(self) -> dict[str, int]:

return output_shapes


def _make_layer(
block: Type[nn.Module],
in_planes: int,
Expand Down Expand Up @@ -567,10 +567,8 @@ def drop_path(x: Tensor, drop_prob: float = 0.0, scale_by_keep: bool = True) ->
@return: Tensor with dropped paths based on the provided drop probability.
"""
keep_prob = 1 - drop_prob
shape = (x.shape[0],) + (1,) * (
x.ndim - 1
)
shape = (x.shape[0],) + (1,) * (x.ndim - 1)
random_tensor = x.new_empty(shape).bernoulli_(keep_prob)
if keep_prob > 0.0 and scale_by_keep:
random_tensor.div_(keep_prob)
return x * random_tensor
return x * random_tensor
15 changes: 9 additions & 6 deletions luxonis_train/nodes/backbones/ddrnet/ddrnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@
Paper: U{https://arxiv.org/pdf/2101.06085.pdf}
@license: U{https://github.com/Deci-AI/super-gradients/blob/master/LICENSE.md}
"""
from abc import ABC
from typing import Dict, Type

import torch
from torch import Tensor, nn
from torch.nn import functional as F

from luxonis_train.nodes.base_node import BaseNode
from luxonis_train.nodes.blocks import ConvModule
from luxonis_train.nodes.heads import DDRNetSegmentationHead

from .blocks import BasicResNetBlock, Bottleneck, UpscaleOnline, BasicDDRBackBone, DAPPM, _make_layer
from .blocks import (
DAPPM,
BasicDDRBackBone,
BasicResNetBlock,
Bottleneck,
UpscaleOnline,
_make_layer,
)


class DDRNet(BaseNode[Tensor, list[Tensor]]):
Expand Down Expand Up @@ -113,7 +116,7 @@ def __init__(
self.backbone_layers, self.additional_layers = self.layers[:4], self.layers[4:]
self.input_channels = input_channels

self._backbone: DDRBackBoneBase = BasicDDRBackBone(
self._backbone = BasicDDRBackBone(
block=self.block,
width=self.planes,
layers=self.backbone_layers,
Expand Down

0 comments on commit fbd6f37

Please sign in to comment.