class_docstr: Demo DETR implementation.
  
  Demo implementation of DETR in minimal number of lines, with the
  following differences wrt DETR in the paper:
  * learned positional encoding (instead of sine)
  * positional encoding is passed at input (instead of attention)
  * fc bbox predictor (instead of MLP)
  The model achieves ~40 AP on COCO val5k and runs at ~28 FPS on Tesla V100.
  Only batch size 1 supported.
class_docstr_tok: ["Demo","DETR","implementation",".","Demo","implementation","of","DETR","in","minimal","number","of","lines",",","with","the","following","differences","wrt","DETR","in","the","paper",":","*","learned","positional","encoding","(","instead","of","sine",")","*","positional","encoding","is","passed","at","input","(","instead","of","attention",")","*","fc","bbox","predictor","(","instead","of","MLP",")","The","model","achieves","~40","AP","on","COCO","val5k","and","runs","at","~28","FPS","on","Tesla","V100",".","Only","batch","size","1","supported","."]
code: def forward(self, inputs):
      # propagate inputs through ResNet-50 up to avg-pool layer
      x = self.backbone.conv1(inputs)
      x = self.backbone.bn1(x)
      x = self.backbone.relu(x)
      x = self.backbone.maxpool(x)
  
      x = self.backbone.layer1(x)
      x = self.backbone.layer2(x)
      x = self.backbone.layer3(x)
      x = self.backbone.layer4(x)
  
      # convert from 2048 to 256 feature planes for the transformer
      h = self.conv(x)
  
      # construct positional encodings
      H, W = h.shape[-2:]
      pos = (
          torch.cat(
              [
                  self.col_embed[:W].unsqueeze(0).repeat(H, 1, 1),
                  self.row_embed[:H].unsqueeze(1).repeat(1, W, 1),
              ],
              dim=-1,
          )
          .flatten(0, 1)
          .unsqueeze(1)
      )
  
      # propagate through the transformer
      # TODO (alband) Why this is not automatically broadcasted? (had to add the repeat)
      f = pos + 0.1 * h.flatten(2).permute(2, 0, 1)
      s = self.query_pos.unsqueeze(1)
      s = s.expand(s.size(0), inputs.size(0), s.size(2))
      h = self.transformer(f, s).transpose(0, 1)
  
      # finally project transformer outputs to class labels and bounding boxes
      return {
          "pred_logits": self.linear_class(h),
          "pred_boxes": self.linear_bbox(h).sigmoid(),
      }
  
imports: from collections import OrderedDict
  import torch
  from torch import nn
  from torch.jit.annotations import Dict
  from torch.nn import functional
label_desc: Use image node_id 2 for calling the DETR obj's underlying member method code with example usage: obj.forward(inputs) and returns: dict