如何使用Tensorflow从随机噪声生成一批3D点云

wljmcqd8  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(111)

我正在尝试从3D中的噪声生成一批点云/网格。我需要它作为一堆初始随机猜测,然后才能在其上应用优化。现有的方法是针对生成航班等定制的。
我的管道目前包括
从噪声生成随机3D图像tf.random.normal/generator -〉调用深度学习模型(Conv 3DTranspose)(输出(64,64,64)-〉验证结果
这种方法的缺点是我没有得到不同的随机点云(它输出相同的类型)
我现在用的是DL模型,因为我没有先验分布,我需要一些东西来从一堆初始的猜测开始。

vvppvyoh

vvppvyoh1#

贝叶斯NN用于解决问题,你可以指定点和随机生成。我可以删除使用Numpy,但我急于回答这个问题的环境。
样本:随机正弦运动。

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()

相关问题