Skip to content

Commit fc79770

Browse files
Update create_train_val_label.py
1 parent ac5e315 commit fc79770

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

create_train_val_label.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json,os
22
import numpy as np
33
import tifffile as tiff
4-
4+
from PIL import Image
55

66

77
def get_label_from_palette(label_img, palette_file='Palette.json'):
@@ -22,7 +22,13 @@ def main(path):
2222
for pic in os.listdir(path):
2323
if 'label' in pic:
2424
print(pic)
25-
label = tiff.imread(path + '/' +pic)
25+
26+
# ---- read RGB label
27+
label = Image.open(path + '/' +pic)
28+
label = np.asarray(label)
29+
# ----- another way
30+
# label = tiff.imread(path + '/' +pic) # the code of this line can be run in windows system, which in ubuntu will get a error !!
31+
2632
label = get_label_from_palette(label)
2733
tiff.imsave(path + '/' +pic[:-9] + 'new-L.tif',label)
2834

0 commit comments

Comments
 (0)