Home > Net >  How can I generate a batch of 3D point clouds from random noise using Tensorflow
How can I generate a batch of 3D point clouds from random noise using Tensorflow

Time:10-06

I am trying to generate a batch of point clouds/mesh from noise in 3D. I need this to act as a bunch of initial random guess before I can apply optimization on top of it. Existing methods are tailored towards generate flights, etc.

My pipeline currently includes

Generate random 3D image from noise tf.random.normal/generator -> Call deep learning model(Conv3DTranspose) (outputs (64,64,64) -> validate results

The drawback with this approach is that I am not getting diverse random point clouds (It outputs the same type)

Is there a way I can do this efficiently. I am using the DL model currently because I don't have the prior distributions and I need something to start with a bunch of initial guesses.

Thank you

CodePudding user response:

Bayesian NN for solving problems, you can specific points and random generated. I can remove using Numpy but I rush to answer this question from environment.

Sample: Random Sine movements.

import os
from os.path import exists

import tensorflow as tf
import tensorflow_io as tfio

import matplotlib.pyplot as plt
import numpy as np

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
None
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
physical_devices = tf.config.experimental.list_physical_devices('GPU')
assert len(physical_devices) > 0, "Not enough GPU hardware devices available"
config = tf.config.experimental.set_memory_growth(physical_devices[0], True)
print(physical_devices)
print(config)

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
: Variables
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
def create_sine_data(n = 2048):

    # pi = np.linspace(0, 180, n)
    pi = 3.141592653589793
    start = 0.0
    stop = 1.0 * 2.0 * pi
    num = n
    
    x = tf.linspace( start, stop, num, name='linspace', axis=0 )
    y1 = 3 * tf.math.sin( x )
    
    escape_sine = tf.random.normal(
        shape=( n, ),
        mean=0.0,
        stddev=0.15 * tf.math.abs( y1, name='abs' ),
        dtype=tf.dtypes.float32,
        seed=32,
        name=None
    )
    
    
    
    y1 = tf.concat( (tf.zeros(60), y1   escape_sine, tf.zeros(60)), axis=0, name='concat' )
    initial_degree = tf.experimental.numpy.arange( -3, 0, 3 / 60, dtype=tf.float32 )
    midring_degree = tf.experimental.numpy.arange( 0, 3 * 2 * pi, ( 3 * 2 * pi) / n, dtype=tf.float32 )
    skipped_degree = tf.experimental.numpy.arange( 3 * 2 * pi, 3 * 2 * pi   3, ( 3 * 2 * pi - 3 * 2 * pi   3 ) / 60, dtype=tf.float32 )
    
    x = tf.concat(( initial_degree.numpy(), midring_degree.numpy(), skipped_degree.numpy()), axis=0, name='concat')
    y2 = 0.1 * x   1
    y = y1   y2
    z = 15 * tf.random.normal(
        shape=( n, ),
        mean=0.0,
        stddev=1,
        dtype=tf.dtypes.float32,
        seed=32,
        name=None
    )

    return x, y, z
    
xdata, ydata, zdata = create_sine_data( )
ax = plt.axes(projection='3d')
# Data for a three-dimensional line
zline = np.linspace(0, 15, 1000)
xline = np.sin(zline)
yline = np.cos(zline)
ax.plot3D(xline, yline, zline, 'gray')
ax.scatter3D(xdata[:100], ydata[:100], zdata[:100], c=zdata[:100], cmap='Greens');


plt.show()

Sample

  • Related