#守护着我的光[超话]#✨#‍每日一善# #阳光信用#
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 举报 写留言 🖊   
✋热门推荐
  • 不如,活在当下享受此刻山顶的风无敌舒服……(12年前的今天高考完的人儿快乐起飞)如今奔三人一枚,这一年多来最大的改变,也是我最喜欢自己的地方就是真的不太在乎别人
  • 然而,35%~40%的患者根治性放化疗后,仍会出现局部复发或远处转移。鼻咽癌患者在治疗后如果出现了复发的情况,一般考虑通过对局部进行放射性治疗,并加以一定阶段的
  • #瑜伽[超话]# #防弹少年团[超话]##防弹少年团0613出道九周年快乐#不知不觉你们也是出道九年的大前辈了 我们即将一起走入第十年 我不是一个做事可以坚持的
  • ​ 且不说有两名女孩儿的情况目前还不明确,如果她们住进了ICU,赔60w也撑不了多久(但是希望小姐姐们平安无事)还能心安理得的出来叫嚣[翻白眼]。​7.说烂了的
  • 直到会期中间,替换了另外的校准源,且直接用M87的观测数据本身做偏振校准,结果不同的小组利用不同方法都可以得到比较一致的初步结果(图4,下)。图1.(上)偏振光
  • #我的旅途打卡地##爱在母亲河畔##阆中古城##天天印象# 2022.6.18.周六.《阆中.丰水期的金银台水电站》(手机影画小品) ​​​​​​ ​​​
  • ”然而,就在这几天我终于深刻的体会到何谓“伤在父身,疼在子女心。只因为我知道无论我长得多大,我都依旧会是您唯一一位,因为您受了一丢丢的伤痛,而忍不住着急得不了的
  • 图:淮阴支行 陆成之(by ha)#南昌买房#【南昌重塑城市新空间提升功能品质】原标题:从有到优 内外兼修南昌重塑城市新空间提升功能品质一座城市的魅力,重要一点
  • 父亲的责任,是要掌好家庭的船舵,无论晴空万里,无论风雨飘摇,都能在生命的深海里,顺利前行。那座碉堡,历经过风吹日晒,却总是在我们受伤、悲恸、无助的时候,给予这世
  • 8、八字带偏财的女命在她们看来物质比爱情重要,但是与正财女不同的是偏财女更加没有底线,只要有钱就能驱使她们,同时在恋爱中偏财女对金钱的要求比正财女更高。她们对于
  • 二、建设单位:衡阳市第七中学。检查组一行先后来到衡阳市七中、玄碧塘小学、衡阳市三中、光明路小学、衡阳市二十三中等学校,通过实地察看走访、查阅台账、开展座谈的方式
  • 小猫咪能有什么烦恼,他只不过想着趁麻麻没看到,想溜出去乱跑,把刚洗完澡的自己搞定脏兮兮,想换一个铲屎换换味道猫粮,也想试一试流浪的日子,想挑战下自己的极限挑战带
  • #文轩[超话]# 有许多新增tie重点️ tie【近期重点】‼️‼️‼️ 希望大家都参与进来哦[航天员] tie很重要喔 步骤: 1️⃣点进博//文//关/
  • #12thAnniversary#说出你与UID Café的故事UID Café岁月回顾之2013年—2014年与你在U37店的时光,是我们宝贵的回忆。在201
  • #武汉牙套[超话]##青年美医进阶计划##微笑计划# ‼️非手术解决严重骨性下巴后缩,追逐闪光演员梦⚪症状:凸面型,骨性下颌后缩,开唇露齿,下唇外翻,双侧尖牙磨
  • #郑业成一念永恒# zyc#郑业成# 针对近期对郑业成先生个人的抹黑,隐射言论,已经严重侵犯到演员个人名誉权权益。针对近期对郑业成先生个人的抹黑,隐射言论,已经
  • 很多人说分享欲是一件很浪漫的事情但是我觉得分享欲被好好接住并且得到了回应才会变得有意义呀~因为至少在那一刻人类的悲喜是相通的✨而且那一刻我们会因为分享变得快乐♥
  • 山脚下古桥边的酒吧,某人指着点餐台上发,舒缓压力的方法,撞头,具体到一二三四个步骤[二哈]疫情间座位的间隔,就这样保留了下来。然后大拇指和食指靠近说,你现在离山
  • 有一次男孩跟朋友喝酒,说起那些事,男孩的朋友跟女孩说,讲的他眼泪都要掉下来了,他是真的很爱你。男孩说反正遇见你真好,从来没有一个人对他怎么好过。
  • 河岛辰德说:“床垫底面也容易泛潮,成为霉菌的温床,因此也要拍打。此外,如果在容易长霉的地方附近使用吸尘器,霉菌有可能会从排气口中飞出,加剧发霉问题,因此需要小心