LoRA CLIP
1.0.0
การแทรก Lora-Layer แบบไดนามิกข้ามภาพหรือตัวเข้ารหัสข้อความหรือตัวเข้ารหัสทั้งสอง
โหลดคลิปเปิดที่ได้รับการฝึกอบรมล่วงหน้าอย่างปลอดภัยในรูปแบบ LORA-IEFIED
โหลดโมเดลพร้อมปรับแต่งอย่างละเอียดโดยไม่ต้องแช่แข็ง positional_embedding , logit_scale และการคาดการณ์
หมายเหตุ: ขณะนี้เราสนับสนุนรุ่น Vision Transformer เฉพาะใน LORA-IFISH ของการเข้ารหัสภาพ รุ่น Resnet จะถูกเพิ่มในไม่ช้า
สำคัญ: ตรวจสอบให้แน่ใจว่าคุณมีคลิปก่อนที่จะติดตั้ง loraclip สิ่งนี้สามารถทำได้โดย
pip install regex ftfy
pip install git+https://github.com/openai/CLIP.git จากนั้นคุณสามารถติดตั้งแพ็คเกจนี้ได้โดยตรงโดยใช้ pip ผ่านคำสั่ง pip install loraclip หรือคุณสามารถพิจารณา buidling สิ่งนี้ได้จากแหล่งที่มาโดย
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