AlanLi1997 / slim-neck-by-gsconv

Pytorch implementation of the 'Slim-neck by GSConv: a lightweight-design for real-time detector architectures'
https://link.springer.com/article/10.1007/s11554-024-01436-6
GNU General Public License v3.0
188 stars 12 forks source link

GSConv implementation #34

Open zeobec opened 3 weeks ago

zeobec commented 3 weeks ago

Currently, im trying to implement GSConv module into Yolov10b module.   conv.py image

task.py image

also imported module in init.py image

.yaml image

however, i received this error message image image

What's the possible reason that could be the source of the error?

AlanLi1997 commented 2 weeks ago

@zeobec You should note the definition of the Conv in YOLOv10. Try to use this GSConv:

  class GSConv(nn.Module):
      # GSConv https://github.com/AlanLi1997/slim-neck-by-gsconv
      def __init__(self, c1, c2, k=1, s=1, g=1, d=1, act=True):
          super().__init__()
          c_ = c2 // 2
          self.cv1 = Conv(c1, c_, k, s, None, g, d, act)
          self.cv2 = Conv(c_, c_, 5, 1, None, c_, d, act)

      def forward(self, x):
          x1 = self.cv1(x)
          x2 = torch.cat((x1, self.cv2(x1)), 1)
          # shuffle
          y = x2.reshape(x2.shape[0], 2, x2.shape[1] // 2, x2.shape[2], x2.shape[3])
          y = y.permute(0, 2, 1, 3, 4)
          return y.reshape(y.shape[0], -1, y.shape[3], y.shape[4])

I have not checked the definition of "Conv" in YOLOv10 yet, so please don't hesitate to let me know if you have any further questions.