💡
코드는 여기서 확인하실 수 있습니다.
상기 이미지를 참고해서 구현했다.
Backbone
, Neck(Top-Down)
, Neck(Bottom-Up)
, Head
로 구성했다.YOLOv7의 모델 구조는 이런 형식으로 되어있다.
파이썬 파일 내 클래스를 생성함으로써 모듈화
Convolution
+ Batch N
+ SiLU
pool_size, stride = (2, 2)
Spatial Pyramid Pooling
+ Cross Stage Partial Network
torch.nn.Upsample(scale_factor=2, mode='nearest')
ELAN과의 차이점
비고 | ELAN | ELAN_W |
---|---|---|
number of blocks to concat | 4 | 6 |
Input | (n , in_channels , h , w) | (n, in_channels, h, w) |
Output | (n, in_channels * 2, h, w) | (n, in_channels // 2, h, w) |
torch.cat([tensor, tensor], dim=n)
dim
으로 지정한 차원 위치 말고는 다 동일해야 함.x1 = torch.rand(n,3,32,32)
x2 = torch.rand(n,3,32,32)
torch.cat([x1, x2], dim=0) 👉 torch.size([n+n, 3, 32, 32])
torch.cat([x1, x2], dim=1) 👉 torch.size([n, 3+3, 32, 32])
torch.cat([x1, x2], dim=2) 👉 torch.size([n, 3, 32+32, 32])
torch.cat([x1, x2], dim=3) 👉 torch.size([n+n, 3, 32, 32+32])
MP-1과 차이점
비고 | MP-1 | MP-2 |
---|---|---|
Input | (n, in_channels, h, w) | (n, in_channels, h, w) |
Output | (n, in_channels, h // 2, w // 2) | (n, in_channels * 2, h // 2, w // 2) |
RepVGG
If training, identity
+ 1x1 conv
+ 3x3 conv
Conv
+ Batch Normalization
+ Sigmoid
YOLOR
’s Implicit
Regression
+ Classification
Output
a list consisting of 3 torch.Tensors
(batch_size, 3, h, w, number of classes +5)
3: number of anchors
5: x+y+w+h+confidence score
x,y : grid cell의 영역에 관련된 bounding box의 center를 의미
[
torch.size([1, 3, 80, 80, 85]),
torch.Size([1, 3, 40, 40, 85]),
torch.Size([1, 3, 20, 20, 85]),
]