predict.py 806 字节
Newer Older
F
FlyingQianMM 已提交
1 2 3 4 5
import numpy as np
from PIL import Image

import paddlex as pdx

F
FlyingQianMM 已提交
6
model_dir = "l8sparcs_remote_model/"
F
FlyingQianMM 已提交
7 8 9 10 11 12 13
img_file = "dataset/remote_sensing_seg/data/LC80150242014146LGN00_23_data.tif"
label_file = "dataset/remote_sensing_seg/mask/LC80150242014146LGN00_23_mask.png"
color = [255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 0, 0, 150, 150, 150]

# 预测并可视化预测结果
model = pdx.load_model(model_dir)
pred = model.predict(img_file)
F
FlyingQianMM 已提交
14
#pred = model.overlap_tile_predict(img_file, tile_size=[512, 512], pad_size=[64, 64], batch_size=32)
F
FlyingQianMM 已提交
15 16 17 18 19 20 21 22
pdx.seg.visualize(
    img_file, pred, weight=0., save_dir='./output/pred', color=color)

# 可视化标注文件
label = np.asarray(Image.open(label_file))
pred = {'label_map': label}
pdx.seg.visualize(
    img_file, pred, weight=0., save_dir='./output/gt', color=color)