🐕

MoE-LLaVAをローカル環境で動かす

2024/02/04に公開

概要

こちらのMoE-LLaVAをローカルで動かしてみます。
https://github.com/PKU-YuanGroup/MoE-LLaVA

環境設定

こちらで動きました。

  • python 3.10.9
  • cuda 11.8

requirements.txt

torch==2.0.1
accelerate==0.21.0
bitsandbytes==0.41.0
deepspeed==0.9.5
einops-exts==0.0.4
einops==0.6.1
gradio==3.35.2
gradio_client==0.2.9
httpx==0.24.0
markdown2==2.4.10
numpy==1.26.0
peft==0.4.0
scikit-learn==1.2.2
sentencepiece==0.1.99
shortuuid==1.0.11
timm==0.6.13
torch==2.0.1
torchvision==0.15.2
#transformers==4.31.0
wandb==0.15.12
wavedrom==2.0.3.post3
Pygments==2.16.1
decord==0.6.0
tiktoken==0.5.2
transformers==4.36.2

importのパスでエラーになったのでパスを追加しました。
MoE-LLaVA/moellava/serve/cli.py

import argparse
import torch

# 以下追加
import sys
sys.path.append("/data_root/MoE-LLaVA/")
# ここまで

from moellava.constants import IMAGE_TOKEN_INDEX, DEFAULT_IMAGE_TOKEN, DEFAULT_IM_START_TOKEN, DEFAULT_IM_END_TOKEN
from moellava.conversation import conv_templates, SeparatorStyle
from moellava.model.builder import load_pretrained_model
from moellava.utils import disable_torch_init
from moellava.mm_utils import process_images, tokenizer_image_token, get_model_name_from_path, KeywordsStoppingCriteria

コマンドラインから実行

deepspeed --include localhost:0 moellava/serve/cli.py --model-path "LanguageBind/MoE-LLaVA-Phi2-2.7B-4e"  --image-file "image.jpg"

こちらの画像を渡して質問します。

USER: describe this image in detail
...
 The image features a group of three people standing in a grassy field, with a large tree nearby. The person in the center of the group is a young girl, wearing a white dress and a white cape. She is standing next to a suitcase, which is placed on the ground in front of her. The other two individuals are also standing close to the girl, creating a sense of companionship.

The scene appears to be set in a picturesque outdoor location, with the grass and the tree providing a natural backdrop for the group. The girl's attire, including her white dress and cape, suggests that she might be on a journey or adventure.

生成速度も速くてよさそうです。

DeepLによる日本語訳

草原に3人のグループが立っており、近くに大きな木がある。グループの中央にいるのは、白いドレスに白いマントを羽織った少女。彼女はスーツケースの横に立っており、スーツケースは彼女の前の地面に置かれている。他の2人も少女の近くに立っており、仲間であるかのような雰囲気を醸し出している。

シーンは絵のように美しい屋外の場所に設定されているように見え、芝生と木がグループの自然な背景となっている。白いドレスとマントという少女の服装は、彼女が旅や冒険の途中であることを示唆している。

Discussion