Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#717 Feature/sg 636 pose estimation metrics

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-636-pose-estimation-metrics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  1. from typing import Union, Tuple, Type
  2. from torch import nn
  3. class ConvBNAct(nn.Module):
  4. """
  5. Class for Convolution2d-Batchnorm2d-Activation layer.
  6. Default behaviour is Conv-BN-Act. To exclude Batchnorm module use
  7. `use_normalization=False`, to exclude activation use `activation_type=None`.
  8. For convolution arguments documentation see `nn.Conv2d`.
  9. For batchnorm arguments documentation see `nn.BatchNorm2d`.
  10. """
  11. def __init__(
  12. self,
  13. in_channels: int,
  14. out_channels: int,
  15. kernel_size: Union[int, Tuple[int, int]],
  16. padding: Union[int, Tuple[int, int]],
  17. activation_type: Type[nn.Module],
  18. stride: Union[int, Tuple[int, int]] = 1,
  19. dilation: Union[int, Tuple[int, int]] = 1,
  20. groups: int = 1,
  21. bias: bool = True,
  22. padding_mode: str = "zeros",
  23. use_normalization: bool = True,
  24. eps: float = 1e-5,
  25. momentum: float = 0.1,
  26. affine: bool = True,
  27. track_running_stats: bool = True,
  28. device=None,
  29. dtype=None,
  30. activation_kwargs=None,
  31. ):
  32. super().__init__()
  33. if activation_kwargs is None:
  34. activation_kwargs = {}
  35. self.seq = nn.Sequential()
  36. self.seq.add_module(
  37. "conv",
  38. nn.Conv2d(
  39. in_channels,
  40. out_channels,
  41. kernel_size=kernel_size,
  42. stride=stride,
  43. padding=padding,
  44. dilation=dilation,
  45. groups=groups,
  46. bias=bias,
  47. padding_mode=padding_mode,
  48. ),
  49. )
  50. if use_normalization:
  51. self.seq.add_module(
  52. "bn",
  53. nn.BatchNorm2d(out_channels, eps=eps, momentum=momentum, affine=affine, track_running_stats=track_running_stats, device=device, dtype=dtype),
  54. )
  55. if activation_type is not None:
  56. self.seq.add_module("act", activation_type(**activation_kwargs))
  57. def forward(self, x):
  58. return self.seq(x)
Discard
Tip!

Press p or to see the previous file or, n or to see the next file