shnhrtkyk / point2color

Point2color: 3D Point Cloud Colorization Using a Conditional Generative Network and Differentiable Rendering for Airborne LiDAR[Earth Vision 2021]
9 stars 4 forks source link

How to inference the color of point clouds? #2

Open Yellowshuohahaha opened 1 year ago

Yellowshuohahaha commented 1 year ago

Hi, thanks for your outstanding work. Could you tell me how to use the pretrained model to predict the color of point clouds? I used the following code, but the result is really bad and the rgb value is close to 0.

transform = transforms.Compose([
    transforms.ToPILImage(),
    transforms.Resize((128, 128)),
    transforms.ToTensor(),
])
train_dataset = ImgtoPointDataset(root="./data/pointcloud_point", transform=transform)
train_loader = DataLoader(train_dataset, batch_size=1, shuffle=True, num_workers=16)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
G = Net(3)
G.cuda()
G.load_state_dict(torch.load("./generator_bestloss.pth", map_location='cpu'))
G.eval()
for i, batch in enumerate(train_loader):
    rgb = batch[0].numpy()
    point  = batch[1].float().numpy()
    geom = batch[2]
    geom = geom.to(device)
    fakergb = G(geom)
    fakergb = fakergb.cpu().detach().numpy()
    rgb = np.squeeze(rgb)
    point = np.squeeze(point)
    pointrealcolor = np.concatenate([point, rgb], axis=1)
    pointfakecolor = np.concatenate([point, fakergb], axis=1)
    np.savetxt("./predict/%d_pointrealcolor.txt" % (i), pointrealcolor)
    np.savetxt("./predict/%d_pointfakecolor.txt"%(i), pointfakecolor)

image

yogkul2000 commented 1 year ago

Hi, thanks for your outstanding work. Could you tell me how to use the pretrained model to predict the color of point clouds? I used the following code, but the result is really bad and the rgb value is close to 0.

transform = transforms.Compose([
    transforms.ToPILImage(),
    transforms.Resize((128, 128)),
    transforms.ToTensor(),
])
train_dataset = ImgtoPointDataset(root="./data/pointcloud_point", transform=transform)
train_loader = DataLoader(train_dataset, batch_size=1, shuffle=True, num_workers=16)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
G = Net(3)
G.cuda()
G.load_state_dict(torch.load("./generator_bestloss.pth", map_location='cpu'))
G.eval()
for i, batch in enumerate(train_loader):
    rgb = batch[0].numpy()
    point  = batch[1].float().numpy()
    geom = batch[2]
    geom = geom.to(device)
    fakergb = G(geom)
    fakergb = fakergb.cpu().detach().numpy()
    rgb = np.squeeze(rgb)
    point = np.squeeze(point)
    pointrealcolor = np.concatenate([point, rgb], axis=1)
    pointfakecolor = np.concatenate([point, fakergb], axis=1)
    np.savetxt("./predict/%d_pointrealcolor.txt" % (i), pointrealcolor)
    np.savetxt("./predict/%d_pointfakecolor.txt"%(i), pointfakecolor)

image

Hi, were you able to fix this?

Yellowshuohahaha commented 1 year ago

Hi, thanks for your outstanding work. Could you tell me how to use the pretrained model to predict the color of point clouds? I used the following code, but the result is really bad and the rgb value is close to 0.

transform = transforms.Compose([
    transforms.ToPILImage(),
    transforms.Resize((128, 128)),
    transforms.ToTensor(),
])
train_dataset = ImgtoPointDataset(root="./data/pointcloud_point", transform=transform)
train_loader = DataLoader(train_dataset, batch_size=1, shuffle=True, num_workers=16)
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
G = Net(3)
G.cuda()
G.load_state_dict(torch.load("./generator_bestloss.pth", map_location='cpu'))
G.eval()
for i, batch in enumerate(train_loader):
    rgb = batch[0].numpy()
    point  = batch[1].float().numpy()
    geom = batch[2]
    geom = geom.to(device)
    fakergb = G(geom)
    fakergb = fakergb.cpu().detach().numpy()
    rgb = np.squeeze(rgb)
    point = np.squeeze(point)
    pointrealcolor = np.concatenate([point, rgb], axis=1)
    pointfakecolor = np.concatenate([point, fakergb], axis=1)
    np.savetxt("./predict/%d_pointrealcolor.txt" % (i), pointrealcolor)
    np.savetxt("./predict/%d_pointfakecolor.txt"%(i), pointfakecolor)

image

Hi, were you able to fix this?

No, I'm still confused about this. Did you meet same problem?

yogkul2000 commented 1 year ago

Yes, facing the same problem

Yellowshuohahaha commented 1 year ago

@shnhrtkyk Hi, can you help us?

werthej commented 3 weeks ago

Have you trained on the 10 las files supplied? Because that's just a tiny fraction of the real data...