Get the backends of all MONAI transforms. Returns: Dictionary, where each key is a transform, and its corresponding values are a boolean list, stating whether that transform supports (1) `torch.Tensor`, and (2) `np.ndarray` as input without needing to con
()
| 1961 | |
| 1962 | |
| 1963 | def get_transform_backends(): |
| 1964 | """Get the backends of all MONAI transforms. |
| 1965 | |
| 1966 | Returns: |
| 1967 | Dictionary, where each key is a transform, and its |
| 1968 | corresponding values are a boolean list, stating |
| 1969 | whether that transform supports (1) `torch.Tensor`, |
| 1970 | and (2) `np.ndarray` as input without needing to |
| 1971 | convert. |
| 1972 | """ |
| 1973 | backends = {} |
| 1974 | unique_transforms = [] |
| 1975 | for n, obj in getmembers(monai.transforms): |
| 1976 | # skip aliases |
| 1977 | if obj in unique_transforms: |
| 1978 | continue |
| 1979 | unique_transforms.append(obj) |
| 1980 | |
| 1981 | if ( |
| 1982 | isclass(obj) |
| 1983 | and issubclass(obj, Transform) |
| 1984 | and n |
| 1985 | not in [ |
| 1986 | "BatchInverseTransform", |
| 1987 | "Compose", |
| 1988 | "CuCIM", |
| 1989 | "CuCIMD", |
| 1990 | "Decollated", |
| 1991 | "InvertD", |
| 1992 | "InvertibleTransform", |
| 1993 | "Lambda", |
| 1994 | "LambdaD", |
| 1995 | "MapTransform", |
| 1996 | "OneOf", |
| 1997 | "RandCuCIM", |
| 1998 | "RandCuCIMD", |
| 1999 | "RandomOrder", |
| 2000 | "PadListDataCollate", |
| 2001 | "RandLambda", |
| 2002 | "RandLambdaD", |
| 2003 | "RandTorchVisionD", |
| 2004 | "RandomizableTransform", |
| 2005 | "TorchVisionD", |
| 2006 | "Transform", |
| 2007 | ] |
| 2008 | ): |
| 2009 | backends[n] = [TransformBackends.TORCH in obj.backend, TransformBackends.NUMPY in obj.backend] |
| 2010 | return backends |
| 2011 | |
| 2012 | |
| 2013 | def print_transform_backends(): |
searching dependent graphs…