#守护着我的光[超话]#✨#‍每日一善# #阳光信用#
Life is like a box of chocolates, you never know what you are going to get.
生活就像一盒巧克力,你永远不知道下一个是什么. ——《阿甘正传》

Sometimes you can't see what you're learning until you come out the other side.
有时候,直到拨云见日,才能豁然开朗。

refer to the following Colab python code,
write a new Colab python code for request :
user import Three View or Multiview orthographic projection image png jpg etc file, loading image to produce 3D cloud point,
write the results on .obj file

! pip install plotly -q

!git clone https://t.cn/A6KTcqVE

%cd shap-e
!pip install -e .

!git clone https://t.cn/A6NRWmuS

#Enter the directory and install the requirements
%cd shap-e
!pip install -e .

from PIL import Image
import torch
from tqdm.auto import tqdm

from point_e.diffusion.configs import DIFFUSION_CONFIGS, diffusion_from_config
from point_e.diffusion.sampler import PointCloudSampler
from point_e.models.download import load_checkpoint
from point_e.models.configs import MODEL_CONFIGS, model_from_config
from point_e.util.plotting import plot_point_cloud

#Implementation and Cooking the 3D models, import all the necessary libraries.
#%cd /content/shap-e
import torch

from shap_e.diffusion.sample import sample_latents
from shap_e.diffusion.gaussian_diffusion import diffusion_from_config
from shap_e.models.download import load_model, load_config
from shap_e.util.notebooks import create_pan_cameras, decode_latent_images, gif_widget

#set the device to cuda if available, otherwise to cpu.
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

#load the models and weights.
xm = load_model('transmitter', device=device)
model = load_model('text300M', device=device)
diffusion = diffusion_from_config(load_config('diffusion'))

#generate the 3D models.
batch_size = 1 # this is the size of the models, higher values take longer to generate.
guidance_scale = 65.0 # this is the scale of the guidance, higher values make the model look more like the prompt.

latents = sample_latents(

batch_size=batch_size,

model=model,

diffusion=diffusion,

guidance_scale=guidance_scale,

model_kwargs=dict(texts=[prompt] * batch_size),

progress=True,

clip_denoised=True,

use_fp16=True,

use_karras=True,

karras_steps=64,

sigma_min=1E-3,

sigma_max=160,

s_churn=0,
)

render_mode = 'stf' #
size = 128 # this is the size of the renders, higher values take longer to render.

cameras = create_pan_cameras(size, device)
for i, latent in enumerate(latents):

images = decode_latent_images(xm, latent, cameras, rendering_mode=render_mode)

display(gif_widget(images))

#save the 3D models as .ply and .obj files.
# Example of saving the latents as meshes.
from shap_e.util.notebooks import decode_latent_mesh

for i, latent in enumerate(latents):

t = decode_latent_mesh(xm, latent).tri_mesh()

with open(f'example_mesh_{i}.ply', 'wb') as f: # this is three-dimensional geometric data of model.

t.write_ply(f)

with open(f'example_mesh_{i}.obj', 'w') as f: # we will use this file to customize in Blender Studio later.

t.write_obj(f)

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

print('creating base model...')
base_name = 'base40M'
base_model = model_from_config(MODEL_CONFIGS[base_name], device)
base_model.eval()
base_diffusion = diffusion_from_config(DIFFUSION_CONFIGS[base_name])

print('creating upsample model...')
upsampler_model = model_from_config(MODEL_CONFIGS['upsample'], device)
upsampler_model.eval()
upsampler_diffusion = diffusion_from_config(DIFFUSION_CONFIGS['upsample'])

print('downloading base checkpoint...')
base_model.load_state_dict(load_checkpoint(base_name, device))

print('downloading upsampler checkpoint...')
upsampler_model.load_state_dict(load_checkpoint('upsample', device))

sampler = PointCloudSampler(

device=device,

models=[base_model, upsampler_model],

diffusions=[base_diffusion, upsampler_diffusion],

num_points=[1024, 4096 - 1024],

aux_channels=['R', 'G', 'B'],

guidance_scale=[3.0, 3.0],
)

from google.colab import files
uploaded = files.upload()

# Load an image to condition on.
img = Image.open('figure_all.jpg')

# Produce a sample from the model.
samples = None
for x in tqdm(sampler.sample_batch_progressive(batch_size=1, model_kwargs=dict(images=[img]))):

samples = x

img

pc = sampler.output_to_point_clouds(samples)[0]

fig = plot_point_cloud(pc, grid_size=3, fixed_bounds=((-0.75, -0.75, -0.75),(0.75, 0.75, 0.75)))

import plotly.graph_objects as go

fig_plotly = go.Figure(

data=[

go.Scatter3d(

x=pc.coords[:,0], y=pc.coords[:,1], z=pc.coords[:,2],

mode='markers',

marker=dict(

size=2,

color=['rgb({},{},{})'.format(r,g,b) for r,g,b in zip(pc.channels["R"], pc.channels["G"], pc.channels["B"])],

)

)

],

layout=dict(

scene=dict(

xaxis=dict(visible=False),

yaxis=dict(visible=False),

zaxis=dict(visible=False)

)

),

)

fig_plotly.show(renderer="colab")

from point_e.util.pc_to_mesh import marching_cubes_mesh

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

print('creating SDF model...')
name = 'sdf'
model = model_from_config(MODEL_CONFIGS[name], device)
model.eval()

print('loading SDF model...')
model.load_state_dict(load_checkpoint(name, device))

import skimage.measure as measure

# Produce a mesh (with vertex colors)
mesh = marching_cubes_mesh(

pc=pc,

model=model,

batch_size=4096,

grid_size=32, # increase to 128 for resolution used in evals

progress=True,
)

# Write the mesh to a PLY file to import into some other program.
with open('figure_all.obj', 'wb') as f:

mesh.write_ply(f)

#苏新皓[超话]##苏新皓 全能ace##苏新皓 山城曙光##苏新皓 三代唯一大主舞#

Don't let other people's opinions dictate your life choices. Only you can decide the direction of the future. Strong confidence, go forward!不要让别人的意见左右你的人生选择,只有你自己能够决定未来的方向。坚定信心,勇往直前!


发布     👍 0 举报 写留言 🖊   
✋热门推荐
  • ”说完又瞪一眼顾清念:“你还挺会指挥,我一药圣,你用的比你们家御医还顺手。”说完又瞪一眼顾清念:“你还挺会指挥,我一药圣,你用的比你们家御医还顺手。
  • 我们要正确地使用好自己神奇的身体,不必向外求,只要向自己的内心深处去寻找本源的力量,只要我们按下接收宇宙高能量信息的“确认键”——放下、接纳、感恩!当我们真正意
  • #皇权富贵[超话]#昊昊 忘了吗在聊理想型时“男女都行”在偶练时“肯定是饭沉沉的声音 我绝对不会认错”“是__饭沉沉呢”“说什么皇权富贵”以及跑遍后台只为给fc
  • “黄经理,我们统计了一下,目前涉及3个自然小区、29个楼门,共计34盏楼门灯存在‘失明’现象,对居民出行造成不便……”“书记您放心,我们一定竭尽所能,春节前让楼
  • #每日一善[超话]#[太阳]#阳光信用# 柳子厚墓志铭 韩愈〔唐代〕  子厚,讳宗元。七世祖庆,为拓跋魏侍中,封济阴公。曾伯祖奭,为唐宰相,与褚遂良、韩瑗俱得
  • 能关注到社会这部分弱势群体的存在很不容易,敏英真的人美心善文案: “没有什么特别的假期,所以真的很开心。去年91这女的找我,说她老公出轨她要离婚看她到底会不会离
  • 本·图克阁下呼吁中国商界利用阿联酋优秀的商业环境,该环境基于国际最佳实践,是进行商业和经济活动的理想地,具有灵活的经济政策和立法,有助于强化阿联酋作为领先经济目
  • 杭州时一起蹦泥巴,鸟巢你说“这五年大家辛苦了”的时候我的眼泪几乎是喷射出来的,上海927你穿着小蓝衣出来的那一刻,我觉得这个男人也太有仪式感了,广州场的花海,宠
  • 答:是的需要,我们提供全程辅导服务,覆盖专业课和复试,让你轻松拿到录取通知书②全日制还是非全日制?(我们提供80%的捷径,你只需要20%努力)[微风]当你在犹豫
  • 9、价值观--追求事业有成,还是生活平衡?有的人追求事业有成,有的人希望工作与生活平衡,如果你希望对方有上进心,就去找一个勤奋的人,如果你希望生活丰富多彩,就去
  • 其实思路还算合理,但我最觉得幽默的是,这货自作主张玩中二搞占有欲,匆匆把人睡了,下一秒就搞“片叶不沾身”人设,甚至用新炮友借此跟受保持距离,放在嬷嬷bot是要被
  • p5是念了一周的蛋挞 然后考完试爸爸就带我去买蛋挞呜呜 p6是我早上起床的美照 妈妈说最近皮肤变好啦~开心 p7是一大早就开始放好运来 嘿嘿嘿迷信一下 p8是
  • 这一声声的呐喊里,有我们对方小米的怜爱,有对大圆满结局的感动之情,也有戏终人散的不舍…有太多太多话想说,但最后都化为了“李云霄”这三个字。[心][心][心][心
  • 竞争对消费者是好事儿,看看未来市场大家会怎么选吧,坦克700 Hi4-T这个价格,我觉得挺狠的,诚意算是拉满了。#凯文聊车##国产豪华车在世界有什么竞争力##坦
  • 非常非常强大*超级厉害的姐姐 强大的姐姐牌孪生姐妹花 同体独立正法仙灵,59灵 最好的女灵 无论功效法力成愿 办事 都非常非常强大的姐姐,此牌为孪生姐妹花,特
  • 在此诚挚的邀请您加入我们工作室这个温暖的大家庭,期待您的加入为我们的大家庭添砖加瓦,是我们的大家庭锦上添花❤️❤️❤️❤️—生生不息,声笙不曦—落霞与孤鹜齐飞,
  • 特別記得高一班上有個自然組性向的同學早就讀完全套金庸,我常常纏著她討論、追問小說情節,甚至她對我極小時因祖父而看的金庸港劇錄影帶尤其主題曲也有共鳴(後來我會收藏
  • 我们现在和 Mobileye 的合作,为什么我们对 Mobileye 充满信心,我们和他们的合作,也考虑了极氪未来的全球市场,欧洲、中东等等,看起来我们迭代速度
  • )不在企鹅在大眼扩也行近期关注都会回的不是很明白wb是怎么搞先发再说企鹅号:3243563927 cn:三角酸奶(直接酸奶/yogurt都可以……!你要是现在有
  • 初三现在睡的呼呼的像只小猪……九点给他喂了第二顿晚饭,库库炫完,盯着我,意犹未尽的样子,感觉还可以再炫十碗。我妈跑完步回来,初三听我俩说话又开始叫[允悲],平常