diff --git a/connectomics/data/utils/data_segmentation.py b/connectomics/data/utils/data_segmentation.py
index 817f1e8f..2b907429 100755
--- a/connectomics/data/utils/data_segmentation.py
+++ b/connectomics/data/utils/data_segmentation.py
@@ -27,7 +27,7 @@ def getSegType(mid):
 
 def relabel(seg, do_type=False):
     # get the unique labels
-    uid = np.unique(seg)
+    uid = np.unique(seg).astype(np.int64)
     # ignore all-background samples
     if len(uid) == 1 and uid[0] == 0:
         return seg
@@ -41,7 +41,7 @@ def relabel(seg, do_type=False):
         m_type = getSegType(mid)
     mapping = np.zeros(mid, dtype=m_type)
     mapping[uid] = np.arange(1, len(uid) + 1, dtype=m_type)
-    return mapping[seg]
+    return mapping[seg.astype(np.int64)]
 
 
 def remove_small(seg, thres=100):
@@ -302,7 +302,7 @@ def seg_to_targets(label_orig: np.ndarray,
             if len(topt) == 1:
                 topt = topt + '-2d-0' # 2d DT without padding (default)
             _, mode, padding = topt.split('-')
-            out[tid] = edt_instance(label.copy(), mode, padding=bool(int(padding))
+            out[tid] = edt_instance(label.copy(), mode, padding=bool(int(padding)))
         elif topt[0] == '6':  # distance transform (semantic)
             if len(topt) == 1:
                 topt = topt + '-2d-8-50'