LoRA CLIP
1.0.0
이미지 또는 텍스트 인코더 또는 두 인코더 전체의 동적 로라 층 삽입.
미리 훈련 된 Openai 클립 웨이트를 LORA 자료 모델로 안전하게로드합니다.
positional_embedding , logit_scale 및 projections를 올바르게 좌절시키지 않으면 미세 조정 준비 모델을로드합니다.
참고 : 현재 이미지 인코더의 LORA-INification에서만 Vision Transformer 모델 만 지원합니다. RESNET 모델이 곧 추가 될 예정입니다.
중요 : loraclip 설치하기 전에 클립이 있는지 확인하십시오. 이것은 단순히 할 수 있습니다
pip install regex ftfy
pip install git+https://github.com/openai/CLIP.git 그런 다음 명령 pip install loraclip 통해 pip 사용 하여이 패키지를 직접 설치할 수 있습니다. 또는 소스에서 이것을 구매하는 것을 고려할 수 있습니다
git clone https://github.com/jaisidhsingh/LoRA-CLIP.git
cd LoRA-CLIP
pip install -e . import loraclip
import argparse
def test_loraclip ( args ):
# Easy-to-use with standard CLIP syntax.
# 1. Dynamic LoRA rank specification
# 2. Specify which encoder(s) to LoRA-ify
model , preprocess = loraclip . load ( args . clip_model_name , device = args . device , r = args . lora_rank , lora_mode = args . lora_mode )
# Utility to preview no. of trainable params along with their % with total params.
loraclip . print_trainable_parameters ( model )
def setup_args ():
parser = argparse . ArgumentParser ()
parser . add_argument ( "--clip-model-name" , type = str , default = "ViT-B/16" )
parser . add_argument ( "--device" , type = str , default = "cuda" )
parser . add_argument ( "--lora-rank" , type = int , default = 4 )
parser . add_argument ( "--lora-mode" , type = str , default = "vision+text" , choices = [ "vision" , "text" , "vision+text" ])
args = parser . parse_args ()
return args
if __name__ == "__main__" :
args = setup_args ()
test_loraclip ( args )https://github.com/openai/clip
https://github.com/sivandoveh/tsvlc