• 大小: 6KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-17
  • 语言: 其他
  • 标签: 3D  

资源简介

3D-keras-3dgan.zip,三维生成对抗网络的keras实现。,3D建模使用专门的软件来创建物理对象的数字模型。它是3D计算机图形的一个方面,用于视频游戏,3D打印和VR,以及其他应用程序。

资源截图

代码片段和文件信息

import sys
import os

import scipy.ndimage as nd
import scipy.io as io
import numpy as np
import matplotlib.pyplot as plt
import skimage.measure as sk

from mpl_toolkits import mplot3d

try:
    import trimesh
    from stl import mesh
except:
    pass
    print ‘All dependencies not loaded some functionality may not work‘

LOCAL_PATH = ‘/home/khushhallchandra/datasets/3DShapeNets/volumetric_data/‘
SERVER_PATH = ‘../data/3DShapeNets/volumetric_data/‘

def getVF(path):
    raw_data = tuple(open(path ‘r‘))
    header = raw_data[1].split()
    n_vertices = int(header[0])
    n_faces = int(header[1])
    vertices = np.asarray([map(floatraw_data[i+2].split()) for i in range(n_vertices)])
    faces = np.asarray([map(intraw_data[i+2+n_vertices].split()) for i in range(n_faces)]) 
    return vertices faces

def plotFromVF(vertices faces):
    input_vec = mesh.Mesh(np.zeros(faces.shape[0] dtype=mesh.Mesh.dtype))
    for i f in enumerate(faces):
        for j in range(3):
            input_vec.vectors[i][j] = vertices[f[j]:]
    figure = plt.figure()
    axes = mplot3d.Axes3D(figure)
    axes.add_collection3d(mplot3d.art3d.Poly3DCollection(input_vec.vectors))
    scale = input_vec.points.flatten(-1)
    axes.auto_scale_xyz(scale scale scale)
    plt.show()

def plotFromVoxels(voxels):
    zxy = voxels.nonzero()
    fig = plt.figure()
    ax = fig.add_subplot(111 projection=‘3d‘)
    ax.scatter(x y -z zdir=‘z‘ c= ‘red‘)
    plt.show()

def getVFByMarchingCubes(voxels threshold=0.5):
    v f =  sk.marching_cubes(voxels level=threshold)
    return v f

def plotMeshFromVoxels(voxels threshold=0.5):
    vf = getVFByMarchingCubes(voxels threshold)
    plotFromVF(vf)

def plotVoxelVisdom(voxels visdom title):
    v f = getVFByMarchingCubes(voxels)
    visdom.mesh(X=v Y=f opts=dict(opacity=0.5 title=title))

def plotFromVertices(vertices):
    figure = plt.figure()
    axes = mplot3d.Axes3D(figure)
    axes.scatter(vertices.T[0:]vertices.T[1:]vertices.T[2:])
    plt.show()

def getVolumeFromOFF(path sideLen=32):
    mesh = trimesh.load(path)
    volume = trimesh.voxel.Voxel(mesh 0.5).raw
    (x y z) = map(float volume.shape)
    volume = nd.zoom(volume.astype(float) 
                     (sideLen/x sideLen/y sideLen/z)
                     order=1 
                     mode=‘nearest‘)
    volume[np.nonzero(volume)] = 1.0
    return volume.astype(np.bool)

def getVoxelFromMat(path cube_len=64):
    voxels = io.loadmat(path)[‘instance‘]
    voxels = np.pad(voxels(11)‘constant‘constant_values=(00))
    if cube_len != 32 and cube_len == 64:
        voxels = nd.zoom(voxels (222) mode=‘constant‘ order=0)
    return voxels

def getAll(obj=‘airplane‘train=True is_local=False cube_len=64 obj_ratio=1.0):
    objPath = SERVER_PATH + obj + ‘/30/‘
    if is_local:
        objPath = LOCAL_PATH + obj + ‘/30/‘
    objPath += ‘train/‘ if train else ‘test/‘
    fileList = [f for f in os.listdir(objPath) if f.endswith(‘.ma

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-07-05 01:41  keras-3dgan-master\
     文件        1045  2017-07-05 01:41  keras-3dgan-master\.gitignore
     文件         349  2017-07-05 01:41  keras-3dgan-master\.travis.yml
     文件        1081  2017-07-05 01:41  keras-3dgan-master\LICENSE
     文件          67  2017-07-05 01:41  keras-3dgan-master\README.md
     目录           0  2017-07-05 01:41  keras-3dgan-master\src\
     文件        3302  2017-07-05 01:41  keras-3dgan-master\src\dataIO.py
     文件        4454  2017-07-05 01:41  keras-3dgan-master\src\models.py
     文件        2932  2017-07-05 01:41  keras-3dgan-master\src\train.py

评论

共有 条评论