网站定做,wordpress酷站,哪个网站可以做ppt模板,seo网站服务公司Urban3D数据集内容简介
Urban3D数据集图像为正摄RGB影像#xff0c;分辨率为50cm。 从SpaceNet上使用aws下载数据#xff0c;文件夹结构为#xff1a;
|- 01-Provisional_Train|- GT|- GT中包含GTC#xff0c;GTI#xff0c;GTL.tif文件#xff0c;GTL为ground truth b…Urban3D数据集内容简介
Urban3D数据集图像为正摄RGB影像分辨率为50cm。 从SpaceNet上使用aws下载数据文件夹结构为
|- 01-Provisional_Train|- GT|- GT中包含GTCGTIGTL.tif文件GTL为ground truth building footprint。|- Inputs|- Inputs中包含DSMDTMRGB.tif文件DSM为Digital Surface ModelsDTM为Digital Terrain Modelsnormalized DSM (nDSM DSM - DTM)
|- 02-Provisional_Test
|- 03-Sequestered_Test
|- 04-Unused_Data
|- AOI_polygons
|- Pretrained_Models|- 包含前6名参赛团队的模型每一块.tif大小为2048*2048。
Urban3D数据集读取
from torchvision import transforms
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import sys
rgb Image.open(/01-Provisional_Train/Inputs/JAX_Tile_016_RGB.tif)
dsm Image.open(/01-Provisional_Train/Inputs/JAX_Tile_016_DSM.tif)
gtl Image.open(/01-Provisional_Train/GT/JAX_Tile_016_GTL.tif)
print(rgb.size, dsm.size, gtl.size) (2048, 2048) (2048, 2048) (2048, 2048)
print(np.array(rgb).shape, np.array(dsm).shape, np.array(gtl).shape) (2048, 2048, 3) (2048, 2048) (2048, 2048)
print(np.array(rgb).dtype, np.array(dsm).dtype, np.array(gtl).dtype) uint8 float32 uint8fig plt.figure()
plt.subplot(131)
plt.imshow(np.array(rgb))
plt.subplot(132)
plt.imshow(np.array(dsm))
plt.subplot(133)
plt.imshow(np.array(gtl))print(np.max(gtl), np.min(gtl)) 6, 2Urban3D数据集Pytorch处理
使用深度学习需要对Urban3D数据进行裁剪这里采用torchvision.transforms.RandomCrop进行裁剪。RandomCrop可以直接作用于PIL.Image打开的文件和torch类型的数据上但不能作用于numpy数组。具体内容可以参考numpy, PIL, tensor类型在torchvision.transforms时使用
def type_convert(x):x_ np.array(x).astype(np.float32)return x_
def to_tensor(x):x_ np.expand_dims(x, axis0)x_ torch.from_numpy(x_)return x_
trans transforms.Compose([transforms.RandomCrop(size256),transforms.Lambda(type_convert),transforms.Lambda(to_tensor)
])torch.random.manual_seed(16)
rgb_crop trans(rgb)
torch.random.manual_seed(16)
dsm_crop trans(dsm)
torch.random.manual_seed(16)
gtl_crop trans(gtl)
print(rgb_crop.size(), dsm_crop.size(), gtl_crop.size())
fig plt.figure()
plt.subplot(131)
plt.imshow(rgb_crop[0,:,:,0])
plt.subplot(132)
plt.imshow(dsm_crop[0,:,:])
plt.subplot(133)
plt.imshow(gtl_crop[0,:,:])同时还需要注意的一点是为了保证RandomCrop后data和label的一致性需要设置随机数种子。对于GTL需要改变label的值。
def type_convert_gtl(x):x_ np.array(x).astype(np.float32)x_[x_6]1x_[x_2]0return x_