如何使用3D模型而不是一百万张图像训练GAN

时间:2019-09-10 18:17:52

标签: tensorflow 3d generative-adversarial-network

我正在尝试使用TensorFlow在椅子的3D模型上训练GAN。这样做的目的是使GAN模型具有椅子的完整上下文,然后可以基于3D模型使用椅子生成图像。

我一直在做的事情是将3D模型读入python,并围绕它的(x,y,z)轴旋转模型并存储图像(用于训练)。结果是从各个角度获得了130万张椅子的图像。我想知道是否有更好的方法,而不是为单个3D模型生成百万张图像。

让GAN学习3D模型,然后使用学习的椅子模型在逼真的场景中生成图像,效率会更高。

我正在使用Python代码旋转3D模型并保存图像

from stl import mesh
from mpl_toolkits import mplot3d
from matplotlib import pyplot

stl_mesh = mesh.Mesh.from_file('./chair.stl')

def generate_save_figure(elev,azim,dist):         
    figure = pyplot.figure(figsize=(1,1))
    axes = mplot3d.Axes3D(figure)
    axes.grid(False)
    axes._axis3don=False    
    axes.add_collection3d(mplot3d.art3d.Poly3DCollection(stl_mesh.vectors))
    scale = stl_mesh.points.flatten(-1)
    axes.auto_scale_xyz(scale, scale, scale)
    axes.view_init(elev=elev,azim=azim)
    axes.dist = dist
    axes.autoscale(True)
    figure.savefig('./numpy-stl-images/elev({})-azim({})-dist({}).png'.format(elev,azim,dist))   
    print('saved elev {}, azim {}, dist {}'.format(elev,azim,dist))
    del figure,axes,scale
    pyplot.close('all')

for elev in range(0,180,1):
    for azim in range(0,360,1):
        for dist in range(5,25,1):
            generate_save_figure(elev,azim,dist)

链接到github存储库,我正在研究此问题的其他上下文(请注意,主席数据集尚不可用) https://github.com/RauxaDataScience/GansContextDataSets

1 个答案:

答案 0 :(得分:0)

https://www.tensorflow.org/graphics/是使用3D数据训练ML模型的答案