Computer Vision News - March 2023

29 with DenseNet Neural Network # Load pretrained Densenet model self.densenet = densenet121(pretrained=True) # Add 3D convolutional layers self.conv1 = nn.Conv3d(1024, 256, kernel_size=3, stride=1, padding=1) self.conv2 = nn.Conv3d(256, 128, kernel_size=3, stride=1, padding=1) self.conv3 = nn.Conv3d(128, n_classes, kernel_size=1, stride=1) def forward(self, x): features = self.densenet.features(x) out = F.relu(self.conv1(features)) out = F.relu(self.conv2(out)) out = self.conv3(out) return out Pretty neat, right?! In this example, we load a pre-trained DenseNet model and add 3D convolutional layers to the end of the network. We then use the output of these layers to produce a segmentation mask withmultiple classes. During training, we can use a loss function such as cross-entropy to compare the output mask to the ground truth segmentation. Conclusion I hope you got a great flavor of different implementations for segmentation networks. I wanted to show you how different frameworks can be applied and how different they are when we implement a solution. At the end of the day, it is up to you to decide which one to use, depending on your familiarity, or the rest of the code (if there is some existing code that you are working on). The most important thing is to get what is really happening behind the scenes; not just memorize or copy the code, but rather be able to create each step and building element! Let me know if you have any questions and if not... then let us meet the month after the next! Next month Again I’ll see you in a couple of months. Meanwhile stay tuned and as always you can enjoy the amazing work done by the magazine and my amazing colleague Marica! Have a wonderful time and always stay curious!

RkJQdWJsaXNoZXIy NTc3NzU=