utils
General functions for experiments and pytorch.
dict_to(data_dict, device)
Move values in dictionary of type torch.Tensor to a specfied device.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_dict |
dict
|
Dictionary to be iterated over. |
required |
device |
device
|
Device to move objects of type torch.Tensor to. |
required |
Returns: Dictionary containing the same keys and values as data_dict, but with all objects of type torch.Tensor moved to the specified device.
Source code in sdfest/initialization/utils.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
set_axes_equal(ax)
Make axes of 3D plot have equal scale.
This ensures that spheres appear as spheres, cubes as cubes, ... This is needed since Matplotlib's ax.set_aspect('equal') and and ax.axis('equal') are not supported for 3D.
From: https://stackoverflow.com/a/31364297
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax |
A Matplotlib axis, e.g., as output from plt.gca(). |
required |
Source code in sdfest/initialization/utils.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
str_to_object(name)
Try to find object with a given name.
First scope of calling function is checked for the name, then current environment (in which case name has to be a fully qualified name). In the second case, the object is imported if found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the object to resolve. |
required |
Returns: The object which the provided name refers to. None if no object was found.
Source code in sdfest/initialization/utils.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
visualize_sample(sample=None, prediction=None)
Visualize sample and prediction.
Assumes the following conventions and keys "scale": Half maximum side length of bounding box. "quaternion: Scalar-last orientation of object.
Source code in sdfest/initialization/utils.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|