vis4d.config.show_connection

Show connected components in the config.

Functions

connect_components(in_info, out_info)

Marks two components as connected.

main(argv)

Main entry point to show connected components in the config.

print_box(title, inputs, outputs[, use_color])

Prints a box with title and in/outputs.

prints_datagraph_for_config(model, ...)

Shows the setup of the configuration objects.

resolve_named_tuple(clazz[, prefix])

Returns all fields defined in the clazz t.

Classes

DataConnectionInfo

Internal type def for visualization.

class DataConnectionInfo[source]

Internal type def for visualization.

This defines a block component

connect_components(in_info, out_info)[source]

Marks two components as connected.

Checks if they have intersecting keys and marks them as matched. Updates the components inplace.

Parameters:
Return type:

None

main(argv)[source]

Main entry point to show connected components in the config. :rtype: None

>>> python -m vis4d.config.show_connection --config vis4d/zoo/faster_rcnn/faster_rcnn_coco.py
print_box(title, inputs, outputs, use_color=True)[source]

Prints a box with title and in/outputs.

Parameters:
  • title (str) – Title to plot in the middle.

  • inputs (list[str]) – inputs to plot on the left.

  • outputs (list[str]) – Outputs to plot on the right.

  • use_color (bool) – Whether to use color in the output.

Returns:

The box as a string.

Return type:

str

Example


<d>-boxes2d | | *boxes2d

<d>-boxes2d_classes | | *boxes2d_classes

<d>-images | Train Data | *images

<d>-input_hw | | *input_hw
prints_datagraph_for_config(model, train_data_connector, test_data_connector, loss, callbacks)[source]

Shows the setup of the configuration objects.

For each components, plots which inputs is connected to which output. Connected components are marked with “*”. Use this to debug your configuration setup.

Note, that data loaded from the dataset are highlighted with <d> and data from model predictions with <p>.

Parameters:
  • model (nn.Module) – Model to plot.

  • train_data_connector (DataConnector) – Train data connector to plot.

  • test_data_connector (DataConnector) – Test data connector to plot.

  • loss (LossModule) – Loss to plot.

  • callbacks (list[Callback]) – Callbacks to plot.

Returns:

The datagraph as a string, that can be printed to the console.

Return type:

str

Example

The following is train datagraph for FasterRCNN with COCO. Inputs loaded from dataset are marked with <d> and predictions with <p>. Unconnected inputs are missing a (*) sign.

>>> dg = prints_datagraph_for_config(model, train_data_connector, test_data_connector, loss, callbacks)))
>>> print(dg)
```
# TODO: check if this is correct
===================================
=          Training Loop          =
===================================
                    --------------
        <d>-boxes2d |            | *boxes2d
<d>-boxes2d_classes |            | *boxes2d_classes
         <d>-images | Train Data | *images
       <d>-input_hw |            | *input_hw
                    --------------
                 --------------
        boxes2d* |            | <p>-proposals
boxes2d_classes* |            | <p>-roi
         images* |            | *<p>-rpn
       input_hw* | FasterRCNN | <p>-sampled_proposals
     original_hw |            | <p>-sampled_target_indices
                 |            | <p>-sampled_targets
                 --------------
                 -----------
    <p>-rpn.cls* |         | cls_outs
    <d>-input_hw |         | images_hw
    <p>-rpn.box* | RPNLoss | reg_outs
     <d>-boxes2d |         | target_boxes
                 -----------
                                ------------
    <p>-sampled_proposals.boxes |          | boxes
     <p>-sampled_targets.labels |          | boxes_mask
              <p>-roi.cls_score |          | class_outs
              <p>-roi.bbox_pred | RCNNLoss | regression_outs
      <p>-sampled_targets.boxes |          | target_boxes
    <p>-sampled_targets.classes |          | target_classes
                                ------------
===================================
=          Testing Loop           =
===================================
                -------------
     <d>-images |           | *images
   <d>-input_hw | Test Data | *input_hw
<d>-original_hw |           | *original_hw
                -------------
                --------------
        boxes2d |            | <p>-boxes
boxes2d_classes |            | <p>-class_ids
        images* | FasterRCNN | <p>-scores
      input_hw* |            |
   original_hw* |            |
                --------------
===================================
=            Callbacks            =
===================================
                    -------------------------
<d>-original_images |                       | *images
   <d>-sample_names |                       | *image_names
          <p>-boxes | BoundingBoxVisualizer | *boxes
         <p>-scores |                       | *scores
      <p>-class_ids |                       | *class_ids
                    -------------------------
                 ----------------------
<d>-sample_names |                     | *coco_image_id
       <p>-boxes |                     | *pred_boxes
      <p>-scores | COCODetectEvaluator | *pred_scores
   <p>-class_ids |                     | *pred_classes
                 ----------------------

```

resolve_named_tuple(clazz, prefix='')[source]

Returns all fields defined in the clazz t.

Use this to get all fields defined for an e.g. Named Tuple.

Parameters:
  • clazz (Any) – Class that should be resolved

  • prefix (str) – Prefix to prepend (will be prefix.<field>)

Return type:

list[str]

Returns:

List with all fields and prefixes prepended.

Examples

>>> Person = namedtuple("Person", ["name", "age", "gender"])
>>> Address = namedtuple("Address", ["street", "city", "zipcode"])
>>> resolve_named_tuple(clazz=Person, prefix="person")
["person.name", "person.age", "person.gender"]
>>> resolve_named_tuple(clazz=Address, prefix="address")
["address.street", "address.city", "address.zipcode"]
>>> resolve_named_tuple(clazz=Person, prefix="")
["name", "age", "gender"]

With more complex types: >>> User = namedtuple(“User”, [“name”, “address”]) >>> user = User(name=Person(name=”John”), address=Address(street=”str”, city=”zrh”, zipcode=”1”))

>>> resolve_named_tuple(clazz=user, prefix="user")
["user.name.name", "user.address.street", "user.address.city",
 "user.address.zipcode"]