Skip to content

Commit 8ae4b7e

Browse files
committed
BUG: The trained model outputs 4 labels now
Due to an error, the trained model output 3 labels but now it has 3. Some small changes to the pipeline doesn't crash
1 parent 8ad532a commit 8ae4b7e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/py/post_process.py

+5
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,11 @@ def ErodeLabel(vtkdata, labels, label):
367367
else:
368368
break
369369

370+
def ReLabel(surf, labels, label, relabel):
371+
for pid in range(labels.GetNumberOfTuples()):
372+
if labels.GetTuple(pid)[0] == label:
373+
labels.SetTuple(pid, (relabel,))
374+
370375
def Threshold(vtkdata, labels, threshold_min, threshold_max):
371376

372377
threshold = vtk.vtkThreshold()

src/py/predict.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def CreatePlane(Origin,Point1,Point2,Resolution):
130130
tree.SetDataSet(surf)
131131
tree.BuildLocator()
132132

133-
label_array = np.zeros([surf.GetNumberOfPoints(), 3])
133+
label_array = np.zeros([surf.GetNumberOfPoints(), 4])
134134

135135
icosahedron = CreateIcosahedron(sphereRadius, numberOfSubdivisions)
136136

@@ -249,12 +249,15 @@ def CreatePlane(Origin,Point1,Point2,Resolution):
249249
for label in range(int(labels_range[0]), int(labels_range[1]) + 1):
250250
print("Removing islands:", label)
251251
post_process.RemoveIslands(surf, real_labels, label, 500)
252+
253+
print("Relabel...")
254+
post_process.ReLabel(surf, real_labels, 3, -2)
252255

253256
print("Connectivity...")
254257
post_process.ConnectivityLabeling(surf, real_labels, 2, 2)
255258

256259
print("Eroding...")
257-
post_process.ErodeLabel(surf, real_labels, 0)
260+
post_process.ErodeLabel(surf, real_labels, -2)
258261

259262
print("Writting:", outfilename)
260263
polydatawriter = vtk.vtkPolyDataWriter()

0 commit comments

Comments
 (0)