MCPcopy
hub / github.com/yerfor/GeneFacePlusPlus / convert_to_tensor

Function convert_to_tensor

utils/commons/tensor_utils.py:65–81  ·  view source on GitHub ↗
(arrays)

Source from the content-addressed store, hash-verified

63
64
65def convert_to_tensor(arrays):
66 if isinstance(arrays, np.ndarray):
67 v = torch.from_numpy(arrays).float()
68 ret = v
69 elif isinstance(arrays, torch.Tensor):
70 ret = arrays
71 elif isinstance(arrays, list):
72 v = torch.from_numpy(np.array(arrays)).float()
73 elif type(arrays) is dict:
74 ret = {}
75 for k, v in arrays.items():
76 if isinstance(v, np.ndarray):
77 v = torch.from_numpy(v).float()
78 if type(v) is dict:
79 v = convert_to_tensor(v)
80 ret[k] = v
81 return ret
82
83def convert_like(inp, target):
84 if isinstance(target, np.ndarray):

Callers 12

find_k_nearest_neighborsFunction · 0.90
euler_trans_2_c2wFunction · 0.90
get_eye_area_percentFunction · 0.90
forward_secc2videoMethod · 0.90
get_lf_boundary_maskFunction · 0.90
get_boundary_maskFunction · 0.90
__init__Method · 0.90
update_extra_stateMethod · 0.85
convert_likeFunction · 0.85
convert_to_halfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected