Hi,
Trying to build and run a custom DNN on Jetson nano but facing incompatibility issues.
The DNN was trained with Pytorch and converted to ONNX format before loading. Customized the “Hello AI world” to run different network (currently it only supports some predefined set of networks)
Details:
Pytorch version: 1.2.0
ONNX: IR version – 0.0.4, opset version – 9
Number of output classes: 2 (softmax layer present)
Labels.txt: Updated with 2 class descriptions
Error:
“imageNet – din’t load expected number of class descriptions (2 of 1)”
“imageNet – failed to load synset class descriptions (2/2 of 1)”
Network definition:
class Network(nn.Module):
def init(self, in_channels = 3, num_classes = 2):
super(Network, self).init()
self.conv1 = nn.Conv2d(3, 32, 3)
self.pool1 = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(32, 64, 3)
self.conv3 = nn.Conv2d(64, 128, 3)
self.conv4 = nn.Conv2d(128, 128, 3)
self.fc1 = nn.Linear(128 * 7 * 7, 512)
self.fc2 = nn.Linear(512, num_classes)
self.sm = nn.Softmax(dim = 1)
def forward(self, x):
x = self.pool1(F.relu(self.conv1(x)))
x = self.pool1(F.relu(self.conv2(x)))
x = self.pool1(F.relu(self.conv3(x)))
x = self.pool1(F.relu(self.conv4(x)))
x = x.view(-1, 128 * 7 * 7)
x = F.relu(self.fc1(x))
x = self.fc2(x)
x = self.sm(x)
return x
ONNX conversion:
import torch.onnx
batch_size = 1
x = torch.randn(batch_size, 3, 150, 150, device=‘cuda’)
torch.onnx.export(net,
x,
“my_classifier.onnx”,
verbose=True
)
Thanks