Shape-E 教程:如何設(shè)置和使用 Shap-E 模型_第1頁
Shape-E 教程:如何設(shè)置和使用 Shap-E 模型_第2頁
Shape-E 教程:如何設(shè)置和使用 Shap-E 模型_第3頁
Shape-E 教程:如何設(shè)置和使用 Shap-E 模型_第4頁
Shape-E 教程:如何設(shè)置和使用 Shap-E 模型_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

Shap-E是OpenAI開發(fā)的一種創(chuàng)新模型,它可以使用文本或圖像作為輸入來生成一系列3D對象,從而改變了3D應(yīng)用領(lǐng)域。這項非凡的技術(shù)可以在GitHub上免費訪問,用戶可以在自己的計算機上無縫運行它,不需要OpenAIAPI密鑰或互聯(lián)網(wǎng)連接。Shap-E的多功能性也是其與眾不同之處,用戶可以將生成的3D對象在MicrosoftPaint3D等軟件中打開,甚至可以轉(zhuǎn)換成STL文件進行3D打印。這項技術(shù)正在重新定義我們處理文本到3D和圖像到3D生成的方式,以及人工智能應(yīng)用程序可以從中產(chǎn)生哪些創(chuàng)造性的可能性。在本教程中,我們將學(xué)習(xí)如何在GoogleColab中創(chuàng)建筆記本,設(shè)置和使用OpenAI的Shap-E模型生成3D模型,并使用BlenderStudio對其進行自定義。首先,您需要前往并下載與您的操作系統(tǒng)兼容的BlenderStudio。接下來,轉(zhuǎn)到GoogleColab并創(chuàng)建一個新的筆記本。在GoogleColab中創(chuàng)建新筆記本現(xiàn)在,我們需要將Shap-E存儲庫克隆到我們的GoogleColabNotebook。!git

clone

/openai/shap-e進入目錄并安裝要求。%cd

shap-e!pip

install

-e

.添加新的codecell.在這里,我們將導(dǎo)入所有必要的庫。import

torchfrom

shap_e.diffusion.sample

import

sample_latentsfrom

shap_e.diffusion.gaussian_diffusion

import

diffusion_from_configfrom

shap_e.models.download

import

load_model,

load_configfrom

shap_e.util.notebooks

import

create_pan_cameras,

decode_latent_images,

gif_widget請點擊“Run”按鈕或按下“CMD/CTRL+Enter”鍵來運行單個代碼塊?,F(xiàn)在,我們將設(shè)置設(shè)備為CUDA(如果可用),否則設(shè)置為CPU。device

=

torch.device('cuda'

if

torch.cuda.is_available()

else

'cpu')單擊Run或CMD/CTRL+Enter。添加新的codecell.在這里,我們將加載模型和權(quán)重。xm

=

load_model('transmitter',

device=device)

model

=

load_model('text300M',

device=device)

diffusion

=

diffusion_from_config(load_config('diffusion'))請點擊“Run”或按下“CMD/CTRL+Enter”鍵。請耐心等待,加載模型和權(quán)重需要一些時間。對我來說,這大約花費了5分鐘的時間。但是,這取決于您的互聯(lián)網(wǎng)連接速度。接下來,我們將生成一個3D模型。batch_size

=

1

#

this

is

the

size

of

the

models,

higher

values

take

longer

to

generate.guidance_scale

=

15.0

#

this

is

the

scale

of

the

guidance,

higher

values

make

the

model

look

more

like

the

mpt

=

"a

donut"

#

this

is

the

prompt,

you

can

change

this

to

anything

you

want.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,)單擊Run或CMD/CTRL+Enter。生成3D模型需要一些時間,根據(jù)您的batch_size更高batch_size將需要更長的時間來生成3D模型。對我來說,生成3D模型大約需要22秒batch_size=1。添加新的codecell.這里我們將渲染3D模型,使用render_mode='nerf'

NeuralRadianceFields(NeRF)來渲染3D模型。您可以將其更改為使用樣式傳遞函數(shù)(STF)render_mode='stf'渲染模式渲染3D模型。render_mode

=

'nerf'

#

you

can

change

this

to

'stf'size

=

64

#

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))請點擊“Run”或按下“CMD/CTRL+Enter”鍵。你看到模型旋轉(zhuǎn)了嗎?很酷,是嗎?接下來,我們將把3D模型保存為.ply和.obj文件。請注意:.obj文件將在稍后在BlenderStudio中用于自定義。#

Example

of

saving

the

latents

as

meshes.from

shap_e.util.notebooks

import

decode_latent_meshfor

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)單擊Run或CMD/CTRL+Enter。將選項卡切換到Files并點擊刷新。您將看到example_mesh_0.ply和example_mesh_0.obj文件。谷歌Colab文件將文件下載.obj到本地計算機。打開BlenderStudio并創(chuàng)建新項目。攪拌機工作室刪除默認(rèn)多維數(shù)據(jù)集。刪除默認(rèn)立方體點擊File>

Import>

Wavefront(.obj)。選擇.obj您從GoogleColab下載的文件。導(dǎo)入.obj文件您應(yīng)該會在中心看到3D模型。3D模型它本身看起來很牛,

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論