コード例 #1
0
ファイル: image_process.py プロジェクト: ShawnXiee/myDL
def expand_resize_data(prediction=None,
                       submission_size=(3384, 1710),
                       offset=690):
    pred_mask = decode_labels(prediction)
    expand_mask = cv2.resize(pred_mask,
                             (submission_size[0], submission_size[1] - offset),
                             interpolation=cv2.INTER_NEAREST)
    submission_mask = np.zeros((submission_size[1], submission_size[0]),
                               dtype='uint8')
    submission_mask[offset:, :] = expand_mask
    return submission_mask
コード例 #2
0
            TA_sum=[]
            for i,j in result["TP"].items():
                TP_sum.append(j)
            for i,j in result["TA"].items():
                TA_sum.append(j)
            TP_sum=np.array(TP_sum)
            TA_sum=np.array(TA_sum)
            TP_sum=TP_sum[1:].sum()
            TA_sum=TA_sum[1:].sum()
            acc='%.5f' %(TP_sum/TA_sum)
            print("acc:",acc)
            acc_all.append(acc)    
            
            pred = pred.detach().cpu().numpy()
            mask = np.squeeze(mask.detach().cpu().numpy())

            for k in range(batch_size):
                pred_=pred[k,:]
                pred_ = decode_labels(np.squeeze(pred_))
                mask_=mask[k,:]
                mp.imsave('./predict/pred/' + str(j*batch_size+k) + '.png', pred_)
                mp.imsave('./predict/label/' + str(j*batch_size+k) + '.png', mask_)
            j=j+1

        print("test_miou_Avr:", np.mean(test_all_miou))
        acc_all = np.array(acc_all, dtype=np.float32)
        print("acc_Avr:", np.mean(acc_all))



                TA_sum.append(j)
            TP_sum = np.array(TP_sum)
            TA_sum = np.array(TA_sum)
            TP_sum = TP_sum[1:].sum()
            TA_sum = TA_sum[1:].sum()
            acc = '%.5f' % (TP_sum / TA_sum)
            print("acc:", acc)
            acc_all.append(acc)

            pred = pred.detach().cpu().numpy()
            mask = mask.detach().cpu().numpy()
            #            print("pred.shape:",pred.shape)
            #            print("mask.shape:",mask.shape)

            for k in range(batch_size):
                pred_ = pred[k, :]
                pred_ = decode_labels(pred_)
                mask_ = mask[k, :]
                #                print("pred_.shape:",pred_.shape)
                #                print("mask_.shape:",mask_.shape)
                mp.imsave('./predict/pred/' + str(j * batch_size + k) + '.png',
                          pred_)
                mp.imsave(
                    './predict/label/' + str(j * batch_size + k) + '.png',
                    mask_)
            j = j + 1

        print("test_miou_Avr:", np.mean(test_all_miou))
        acc_all = np.array(acc_all, dtype=np.float32)
        print("acc_Avr:", np.mean(acc_all))