Python 预测后如何生成准确的掩模

Python 预测后如何生成准确的掩模,python,opencv3.0,Python,Opencv3.0,我正在使用深度学习方法进行分割任务,训练后我想对测试图像进行预测。为此,我首先加载模型和图像,然后将生成的遮罩保存到文件夹中 ,我使用了这个代码 model = load_model('..../accuracy.h5')#loading the model TEST_PATH = ''#path to my test images PRED_PATH = ''#path to where I want to save my generated masks #this block is use

我正在使用深度学习方法进行分割任务,训练后我想对测试图像进行预测。为此,我首先加载模型和图像,然后将生成的遮罩保存到文件夹中 ,我使用了这个代码

model = load_model('..../accuracy.h5')#loading the model
TEST_PATH = ''#path to my test images
PRED_PATH = ''#path to where I want to save my generated masks 
#this block is used to read my test images and save them into X
test_ids  = os.listdir(TEST_PATH)
X = np.zeros((len(test_ids), IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS), dtype=np.uint8)
ctr=0
for n, id_ in tqdm(enumerate(test_ids), total=len(test_ids)):
    path = TEST_PATH + id_
    image_file = os.listdir(path + '/images/')
    X[ctr]  = imread(path+'/images/'+image_file[0])[:,:,:IMG_CHANNELS]
    ctr=ctr+1
 
preds_test = model.predict(X, verbose=1)#predictions on my images
#this block is used to save the generated mask intoa folder
ctr=0
for i in range(len(test_ids)):
    file_name=test_ids[i]+'pred.png'
    img=preds_test[ctr]
    imsave(PRED_PATH+file_name,img)
    ctr= ctr+1
这是生成的掩码的一个示例

面具的质量不好,我不知道我在预测过程中是否遗漏了一些东西!谁能帮帮我吗