GPU-based indexing and retrieval pipeline for LoRAs
Project description
CARLoS — CLIP-based LoRA Retrieval & Indexing
🚀 Quick Start
# 1. Create environment
conda create -n carlos python=3.9.16 -y
conda activate carlos
# 2. Install PyTorch with CUDA 12.6 and a requirements file
python -m pip install --extra-index-url https://download.pytorch.org/whl/cu126 -r requirements-cu126.lock.txt
# 3. Install CARLoS
pip install carlos
import carlos
# Load a writable copy of the bundled database
carlos.copy_bundled_database("metrics.parquet", overwrite=False)
db = carlos.load_database("metrics.parquet")
# Run a retrieval query
results = carlos.retrieve(db, "snowfall, cold winter scene", top_k=5)
for r in results:
print(r.rank, r.lora_id, r.score)
Overview
CARLoS is a GPU-backed retrieval and indexing library for Stable Diffusion LoRA modules.
It supports two distinct workflows:
-
Retrieval (lightweight, GPU required but relatively cheap)
Query a prebuilt LoRA metrics database using natural language and retrieve the most relevant LoRAs. -
Indexing (heavy, GPU-intensive)
Download a new LoRA (e.g. from CivitAI), generate images, compute CLIP-based metrics, and upsert the result into a local database.
The project is designed as:
- a clean Python library (
pip install carlos) - reproducible via conda
- GPU-first (CUDA handled outside pip)
- safe for public use (no research artifacts exposed)
Requirements & Assumptions
- Python: 3.9.x
- GPU: NVIDIA GPU required
- CUDA: Managed via conda or PyTorch wheels
- OS: Linux recommended
- Storage: Parquet-backed database
⚠️ CPU-only execution is not supported.
Installation
Create Conda Environment
conda create -n carlos python=3.9.16 -y
conda activate carlos
Install PyTorch with CUDA
python -m pip install --extra-index-url https://download.pytorch.org/whl/cu126 -r requirements-cu126.lock.txt
Verify:
python -c "import torch; print(torch.cuda.is_available(), torch.version.cuda)"
Install CARLoS
pip install carlos
Public API
Most users only need:
import carlos
Main entry points:
carlos.copy_bundled_databasecarlos.load_databasecarlos.retrievecarlos.index_lora
Retrieval Example
from pathlib import Path
import carlos
out_dir = Path("/path/to/output")
out_dir.mkdir(parents=True, exist_ok=True)
db_parquet = out_dir / "metrics_database.local.parquet"
carlos.copy_bundled_database(db_parquet, overwrite=False)
db = carlos.load_database(db_parquet)
queries = [
"snowfall, cold winter scene, visible breath",
"oil painting style",
"pixel art style",
]
for q in queries:
results = carlos.retrieve(db, q, top_k=10)
print(f"\nQuery: {q}")
for r in results:
print(f"[{r.rank}] id={r.lora_id} score={r.score:.4f}")
Indexing Example (GPU-Heavy)
from pathlib import Path
import carlos
model_id = "2300298"
version_id = "2588340"
out_dir = Path("/path/to/output")
out_dir.mkdir(parents=True, exist_ok=True)
db_parquet = out_dir / "metrics_database.local.parquet"
carlos.copy_bundled_database(db_parquet, overwrite=False)
db = carlos.load_database(db_parquet)
result = carlos.index_lora(
db,
lora_source="civitai",
model_id=model_id,
version_id=version_id,
overwrite=False,
working_directory=out_dir / "work",
)
db.save_parquet(db_parquet)
print("Indexed:", result.row["version_id"])
print("Strength:", result.vector.strength)
print("Consistency:", result.vector.consistency)
CivitAI Access (Optional)
export CIVITAI_API_KEY=your_key_here
Development Philosophy
src/layoutpyproject.toml- minimal public API
- no generated artifacts committed
- GPU runtime handled externally
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file carlos-0.0.3.tar.gz.
File metadata
- Download URL: carlos-0.0.3.tar.gz
- Upload date:
- Size: 2.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8aa6fa4dad7002d2899cf4b1bb4faf05b95c60e96c2b72b7abd7d17a180cba9b
|
|
| MD5 |
8eee766ae1769219367dd07f54a7fabe
|
|
| BLAKE2b-256 |
5c7ce5a1fb48c4615dc99689c1671c352403287686232bec192d7c49c77fd897
|
File details
Details for the file carlos-0.0.3-py3-none-any.whl.
File metadata
- Download URL: carlos-0.0.3-py3-none-any.whl
- Upload date:
- Size: 2.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94d2f4bd246289bfc15c13d05ef1164dede3bbc812c632081645e54a677bb2a3
|
|
| MD5 |
957915dacaf33c68f8b4d5e8d00f1094
|
|
| BLAKE2b-256 |
d35f4c4413fe584e716cc04e601926fe2323f81d7ccb0b8bfb2597cda36beebe
|