見出し画像

Google Colab で Stable Zero123 を試す

「Google Colab」で「Stable Zero123」を試したので、まとめました。

【注意】Google Colab Pro/Pro+のA100で動作確認しています。


1. Stable Zero123

Stable Zero123」は、「Zero123」に基づく単一画像からの高品質3Dオブジェクト生成のモデルです。改善されたデータレンダリングとモデルコンディショニング戦略により、「Zero123」「Zero123-XL」と比較して、パフォーマンスが向上しました。「Stable Zero123」モデルと一緒に「スコア蒸留サンプリング」(SDS)を使用することで、あらゆる入力画像から高品質の3Dモデルを作成できます。

2. Stable Zero123のモデル

「Stable Zero123」は、現在1つのモデルのみが提供されています。

stabilityai/stable-zero123 

3. Colabでの実行

Colabでの実行手順は、次のとおりです。

(1) Colabのノートブックを開き、メニュー「編集 → ノートブックの設定」で「GPU」で「A100」を選択。

(2) リポジトリのクローン。

# パッケージのインストール
!git clone https://github.com/threestudio-project/threestudio
%cd threestudio

(3) パッケージのインストール。
ビルドがあるので、20分ほどかかりました。

# パッケージのインストール
!pip install ninja
!pip install lightning==2.0.0 omegaconf==2.3.0 jaxtyping typeguard diffusers transformers accelerate opencv-python tensorboard matplotlib imageio imageio[ffmpeg] trimesh bitsandbytes sentencepiece safetensors huggingface_hub libigl xatlas networkx pysdf PyMCubes wandb torchmetrics controlnet_aux
!pip install einops kornia taming-transformers-rom1504 git+https://github.com/openai/CLIP.git # zero123
!pip install open3d plotly # mesh visualization

!pip install git+https://github.com/ashawkey/envlight.git
!pip install git+https://github.com/KAIR-BAIR/nerfacc.git@v0.5.2
!pip install git+https://github.com/NVlabs/nvdiffrast.git
!pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

(4) モデルのダウンロード。

# モデルのダウンロード
!wget -P load/zero123/ https://huggingface.co/stabilityai/stable-zero123/resolve/main/stable_zero123.ckpt

(5) 画像の準備して、threestudio/load/imagesに配置。
ChatGPT (DALL-E 3) で3Dモデル風の画像を生成して、背景を透過しました。

・girl_rgba.png (512x512px、透過png)


(6) 3Dレンダリング。
7分ほどで生成完了します。outputsに結果が出力されます。

# 3Dレンダリング
!python launch.py --config configs/stable-zero123.yaml --train --gpu 0 data.image_path=./load/images/girl_rgba.png

4. エクスポート

エクスポートの手順は、次のとおりです。

(1) エクスポートの実行。
コンフィグとチェックポイントのパスは自分のパスに書き換えてください。2分ほどで生成完了します。outputsに結果が出力されます。

!python launch.py \
    --config "outputs/zero123-sai/[64, 128, 256]_girl_rgba.png@20231215-224503/configs/parsed.yaml" \
    --export \
    --gpu 0 \
    resume="outputs/zero123-sai/[64, 128, 256]_girl_rgba.png@20231215-224503/ckpts/last.ckpt" \
    system.exporter_type=mesh-exporter \
    system.exporter.context_type=cuda

次回



この記事が気に入ったらサポートをしてみませんか?