Dynamische Lora-Schicht-Einfügung über Bild- oder Textcodierer oder beide Encoder.
Lädt vor ausgebildetem OpenAI-Clipgewichten sicher in das Lora-Iffizier-Modell.
Lädt Feinabstimmungsmodelle durch korrektes Einfrieren positional_embedding , logit_scale und Projektionen.
HINWEIS: Wir unterstützen derzeit nur Sehtransformatormodelle in der Lora-IFFILE von Bildcodierern. Resnet -Modelle werden in Kürze hinzugefügt.
Wichtig: Stellen Sie sicher, dass Sie Clip haben, bevor Sie loraclip installieren. Dies kann einfach von erledigt werden durch
pip install regex ftfy
pip install git+https://github.com/openai/CLIP.git Sie können dieses Paket dann direkt über pip über die Befehls pip install loraclip installieren. Alternativ können Sie in Betracht ziehen, dies von Quelle von Quelle zu kauft
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/ivandoveh/tsvlc