LoRA-CLIP: Easy Wrapper for LoRA-ifying CLIP
Features
-
Dynamic LoRA-layer insertion across image or text encoder, or both encoders.
-
Loads pre-trained OpenAI CLIP weights safely into LoRA-ified model.
-
Loads fine-tuning ready models by correctly un-freezing
positional_embedding,logit_scale, and projections.
Note: We currently only support Vision Transformer models in the LoRA-ification of image encoders. ResNet models will be added soon.
Installation
IMPORTANT: make sure you have CLIP before you install loraclip. This can simply be done by
pip install regex ftfy
pip install git+https://github.com/openai/CLIP.git
You can then install this package directly using pip via the command pip install loraclip. Alternatively, you can consider buidling this from source by
git clone https://github.com/jaisidhsingh/LoRA-CLIP.git
cd LoRA-CLIP
pip install -e .
Usage
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)
References
Metadata
Release files for loraclip 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| loraclip-0.1.0.tar.gz | 20.0 kB | Without provenance | Details for loraclip-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loraclip-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for loraclip-0.1.0-py3-none-any.whl |
Total release size: 39.8 kB
Release files / loraclip-0.1.0.tar.gz
| Download URL | loraclip-0.1.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57c931039fffa6d9beaeded31a7dd86b003741fa9787af61d6c335e8ab22bc9a
|
|
BLAKE2b-256 checksum How to use checksums |
73b10dd6e53018d669bf1fd043d1793f223ce291b57b6977ea101be1bfb03f4c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.5
|
Release files / loraclip-0.1.0-py3-none-any.whl
| Download URL | loraclip-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c997ba70de468dfb312e600e72fe244d7109c3a20ee3f6d9ac969de72aa74213
|
|
BLAKE2b-256 checksum How to use checksums |
d780e473569c04b81021c8ac3735cd325b8de21a2033262f56453a9df337758e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.9.5
|
Security for loraclip 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.