AarohiSingla / YOLOv7-POSE-on-Custom-Dataset

Keypoint detection on custom dataset. We have 1 class - Glass and it have 4 keypoints. Ithis this tutorial we will train our yolov7 model to detect these 4 custom keypoints
17 stars 9 forks source link

Can't get attribute 'SPPF' #4

Open jwee1369 opened 1 year ago

jwee1369 commented 1 year ago

Can't get attribute 'SPPF' on <module 'models.common' from '/media/jwee/SSD2TB/Local/00_Artificial_Intelligence/Tutorial/04_Yolo/YOLOv7-POSE-on-Custom-Dataset/models/common.py'

mingun0112 commented 12 months ago

just add this class on models/common.py

class SPPF(nn.Module):
    # Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher
    def __init__(self, c1, c2, k=5):  # equivalent to SPP(k=(5, 9, 13))
        super().__init__()
        c_ = c1 // 2  # hidden channels
        self.cv1 = Conv(c1, c_, 1, 1)
        self.cv2 = Conv(c_ * 4, c2, 1, 1)
        self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)

    def forward(self, x):
        x = self.cv1(x)
        y1 = self.m(x)
        y2 = self.m(y1)
        return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))

It could be working