Hello i am trying to calculate average surface distance (asd) using Medpy with latest libraries of keras and tensorflow. Any help in this regard is appreciated. Here is my code and error:
from medpy import metric as M
asd=M.binary.asd(tf.cast(y_pred, np.float32),tf.cast(y_true, np.float32),voxelspacing=None,connectivity=1)
Error:
File "/home/rak038/Segmentation/U-net/noGPU/noGPU/lib/python3.7/site-packages/medpy/metric/binary.py", line 1200, in __surface_distances
result = numpy.atleast_1d(result.astype(numpy.bool))
AttributeError: 'Tensor' object has no attribute 'astype'
astype is a Numpy function. Here I guess result is a tf.Tensor, so you need to use tf.cast to change its type instead (see https://www.tensorflow.org/api_docs/python/tf/cast).
tensor.numpy() can change your type from tensor to numpy, it will have the attribute astype
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With