생성된 이미지에 일관성을 유지하며 애니메이션으로 만들기


AnimateDiff: Animate Your Personalized Text-to-Image Diffusion Models without Specific Tuning
https://github.com/guoyww/AnimateDiff

https://animatediff.github.io/

https://civitai.com/models/108836



//-------------------------------------
    - 실행 환경 준비(git bash)
git clone https://github.com/guoyww/AnimateDiff.git
cd AnimateDiff

conda env create -f environment.yaml

conda activate animatediff


//-------------------------------------
* git bash에서 실행시 conda 에러 발생

    - 에러 메시지
bash: conda: command not found

    - 해결 방법
    - 사용중인 conda의 conda.sh를 검색해서 다음 명령을 실행하면 된다.

$ . c:/ProgramData/Miniconda3/etc/profile.d/conda.sh


//-------------------------------------
    - 기본 T2I 및 모션 모듈 체크포인트 다운로드 
git lfs install
git clone https://huggingface.co/runwayml/stable-diffusion-v1-5 models/StableDiffusion/stable-diffusion-v1-5
    - 이미 폴더가 있어서 실행이 안되면 폴더이름을 변경해서 실행후 덮어쓴다. 시간 오래걸림 30G

bash download_bashscripts/0-MotionModule.sh

//-------------------------------------
https://huggingface.co/guoyww/animatediff/tree/main
mm_sd_v14.ckpt, mm_sd_v15.ckpt, mm_sd_v15_v2.ckpt 다운로드해서 models/Motion_Module 폴더로 이동



//-------------------------------------
    - 모델 다운로드 스크립트 샘플 폴더 : download_bashscripts
    - 다운로드 실행
bash download_bashscripts/1-ToonYou.sh


//-------------------------------------
    - 애니메이션 생성 설정 파일 샘플 폴더 : configs/prompts
    - 애니메에션 생성 샘플 실행 방법 
$ python -m scripts.animate --config configs/prompts/1-ToonYou.yaml

//-----------------------------------------------------------------------------
    - 설정 샘플 (mm_sd_v14 용)
    - test14.yaml (실행시간 1.4= 68초(1.83s/it)), 1.5= 68초(1.83s/it),  1.5v2=( 68초(1.83s/it)) )

test14:
  base: ""
  path: "models/DreamBooth_LoRA/toonyou_beta3.safetensors"
  motion_module:
    - "models/Motion_Module/mm_sd_v14.ckpt"

  seed:           [10788741199826055526]
  steps:          25
  guidance_scale: 7.5

  prompt:
    - "best quality, masterpiece, 1boy, formal, abstract, looking at viewer, masculine, marble pattern"

  n_prompt:
    - ""

 

 

    - 실행
python -m scripts.animate --config configs/prompts/test14.yaml


//-----------------------------------------------------------------------------
    - mm_sd_v15_v2 용 설정 샘플
    - test15v2.yaml


test15v2:
  base: ""
  path: "models/DreamBooth_LoRA/toonyou_beta3.safetensors"
  
  inference_config: "configs/inference/inference-v2.yaml"

  motion_module:
    - "models/Motion_Module/mm_sd_v15_v2.ckpt"

  seed:           [10788741199826055526]
  steps:          25
  guidance_scale: 7.5

  prompt:
    - "best quality, masterpiece, 1boy, formal, abstract, looking at viewer, masculine, marble pattern"

  n_prompt:
    - ""


//-----------------------------------------------------------------------------
    - triton 설치 문제 해결방법

    - 실행 에러 메시지
A matching Triton is not available, some optimizations will not be enabled.
Error caught was: No module named 'triton'


$ pip install triton
ERROR: Could not find a version that satisfies the requirement triton (from versions: none)
ERROR: No matching distribution found for triton

$ pip index versions triton
ERROR: No matching distribution found for triton

    - 해결방법
    - triton은 윈도우용 빌드가 정식으로 제공되지 않는다.
https://github.com/openai/triton/issues/1057
$ pip install https://huggingface.co/r4ziel/xformers_pre_built/resolve/main/triton-2.0.0-cp310-cp310-win_amd64.whl


//-----------------------------------------------------------------------------
    - 실행 속도

pip install accelerate 설치 => 영향 없음
pytorch v2 설치 => 영향 없음

//-----------------------------------------------------------------------------
    - web-ui 가능
$ conda activate animatediff
$ python app.py
접속 주소 :  http://localhost:7860

 

반응형
Posted by codens