View Source PostDNN (postdnn v0.1.4)

Post-processing utilities for Deep Neural Network.

Link to this section Summary

Functions

Adjust NMS result to aspect of the input image. (letterbox)

Bounds value in {lower, upper}.

Create a list of (x,y) coordinates for mesh grid points - top-left of each grid.

Create a priorbox which is a list of the coodinate of the boxes in each grid.

Take records satisfying the predicate function pred? from table.

Link to this section Functions

Link to this function

adjust2letterbox(nms_result, aspect \\ [1.0, 1.0])

View Source

Adjust NMS result to aspect of the input image. (letterbox)

parameters

Parameters:

  • nms_result - NMS result {:ok, result}
  • [rx, ry] - aspect ratio of the input image

Bounds value in {lower, upper}.

Link to this function

meshgrid(shape, pitches, opts \\ [])

View Source

Create a list of (x,y) coordinates for mesh grid points - top-left of each grid.

parameters

Parameters

  • shape - tupple {width, height} for overall size.
  • pitches - list of grid spacing.
  • opts
    • :center - return center of each grid.
    • :transpose - return transposed table
    • :normalize - normalize (x,y) cordinate to {0.0..1.0}
    • :rowfirst - change to row scan first. (default: column scan first)

examples

Examples

  meshgrid({416,416}, [8,16,32,64], [:center])
Link to this function

non_max_suppression_multi_class(arg, boxes, scores, opts \\ [])

View Source

Execute post processing: nms.

parameters

Parameters

  • num_boxes - number of candidate boxes
  • num_class - number of category class
  • boxes - binaries, serialized boxes tensor[num_boxes][4]; dtype: float32
  • scores - binaries, serialized score tensor[num_boxes][num_class]; dtype: float32
  • opts
    • iou_threshold: - IOU threshold
    • score_threshold: - score cutoff threshold
    • sigma: - soft IOU parameter
    • boxrepr: - type of box representation
      • :center - center pos and width/height
      • :topleft - top-left pos and width/height
      • :corner - top-left and bottom-right corner pos
    • label: map - replace "number" with "name" label according to a map %{0 => "foo", 1 => "baa", ...}
    • label: path - given a file path, read it and create the label map

examples

Examples

  non_max_suppression_multi_class(
    Nx.shape(scores), Nx.to_binary(boxes), Nx.to_binary(scores), boxrepr: :corner
  )
Link to this function

priorbox(shape, pitch_boxes, opts \\ [])

View Source

Create a priorbox which is a list of the coodinate of the boxes in each grid.

parameters

Parameters

  • shape - tupple {width, height} for overall size.
  • pitch_boxes - list of tupples which have grid spacing and boxes size.
  • opts
    • :transpose - return transposed table
    • :normalize - normalize (x,y) cordinate to {0.0..1.0}
    • :rowfirst - change to row scan first. (default: column scan first)

examples

Examples

  priorbox({416,416}, [{8, [8, 10, 15]}, {16, [16, 20]}], [:normalize])

Take records satisfying the predicate function pred? from table.

parameters

Parameters

  • tensor - 2rank tensor (table). each row represents a record.
  • pred? - predicate function to sieve records. a function that returns a rank1 tensor with '1' in the index position of records to be kept and '0' in the index position of those to be discarded.

examples

Examples

  pred? = fn tensor -> Nx.greater(tensor, 0.2) end
  sieve(table, pred?)
Link to this function

sieve(tensor_a, list, pred?)

View Source