AllastorV/LoRA-Harvester

AI-Powered Video Processing Tool for LoRA Training Dataset Creation.

1

stars

2

commits

Python

primary language

Aug 7, 2026

updated

ai
anime
computer-vision
dataset
dataset-creation
deep-learning
diffusion-models
frame-extraction
image-processing
kohya-ss
lora
lora-training
machine-learning
python
stable-diffusion
training-data
upscaling
video-processing
Browse cluster: Diffusion Models & Image Generation

README

LoRA-Harvester

LoRA-Harvester v4.0

AI-Powered Video → LoRA Training Dataset Creator

Yapay Zeka Destekli Video → LoRA Eğitim Dataseti Oluşturucu

Python PyTorch License GitHub

English | Türkçe


ENGLISH

What's New in v4.0

  • 📝 Subtitle detection rewritten — works at any resolution and aspect ratio (16:9, 9:16, 480p…), detects single-line and top-positioned subtitles, and scans the full frame for text lines instead of a fixed bottom band
  • ✂️ Smarter subtitle removal — frames are cropped from the correct side (top or bottom) and the crop shrinks around overlay/subtitle zones instead of falling back to an unconstrained crop
  • 🖥️ System monitor fixed — GPU utilization and VRAM now read device-wide via nvidia-smi (with a torch.cuda.mem_get_info fallback), so real usage shows up even while training runs in a subprocess or torch is CPU-only
  • 🔁 --no-resume actually works — the CLI flag is now wired through to the processor
  • 🐛 Bug fixes — duplicate translation keys caused the wrong tooltip on the detection-confidence spinbox; duplicate _spinbox_style method removed
  • 🧹 Codebase cleanup — 7 unused legacy modules removed, dead imports cleaned across 16 files, caches and stale files purged

What's New in v3.0

  • 🧩 Caption Studio — one page for both auto-generation (WD14) and manual editing, with live Danbooru tag autocomplete while you type
  • 🎯 Quality presets — pick High Accuracy / Balanced / High Speed; the best WD14 model, confidence, and tag count are chosen for you
  • 🔖 Trigger + Suffix — prepend a LoRA keyword and append quality tokens in the same UI
  • 🖼️ Florence-2 — optional natural-language captions for full-sentence alt-text
  • ✂️ SAM2 + PySceneDetect — subject-aware masking and cut-level deduplication
  • 🎨 Dark / Light theme + font scaling + differentiated Start/Pause/Skip/Stop buttons

What Is It?

LoRA-Harvester extracts high-quality frames from videos, sorts them by character using face recognition, and optionally generates captions — producing a clean, ready-to-train LoRA dataset in minutes instead of hours.

Main workflow:

Video(s) → Extract frames → AI detects person → Smart crop → Quality filter → Caption → Dataset

Character Sorter workflow:

Image folder → Face detection → Match / cluster by identity → Sort into named folders

Features

FeatureDetails
AI DetectionYOLOv8 single-model detector (fast, modern replacement for the old 3-model ensemble)
Scene DetectionOptional PySceneDetect integration — skips duplicate-ish content between cuts
Smart CropAspect-ratio aware crop with configurable padding, SAM2-assisted subject masking
Overlay AwarenessDetects logos/watermarks and crops around them
Quality FilterBlur, noise, brightness, and duplicate detection
Character SorterInsightFace face recognition to sort images by character identity
Max CharactersLimit output to 1–6 character folders; extras go to other/
Caption StudioSingle page merging Generate (WD14 tagging) + Edit (Danbooru autocomplete)
Tagging PresetsOne-click High Accuracy / Balanced / High Speed — auto-picks the best WD14 model
Trigger + SuffixPrepend a LoRA keyword and append quality tokens in one place
Natural-LanguageOptional Florence-2 captions for descriptive, full-sentence alt-text
Tag FrequencyScan a caption folder, count tag usage, bulk-remove unwanted tags across files
xformersOpt-in memory-efficient attention for Florence-2 / SAM2 on supported GPUs
Turbo ModeBatch frame processing for maximum throughput
CheckpointResume interrupted processing from where it stopped
Bilingual UIEnglish / Turkish interface, full dark/light theme switching

Installation

# 1. Clone the repository
git clone https://github.com/AllastorV/LoRA-Harvester.git
cd LoRA-Harvester

# 2. Create a virtual environment
python -m venv venv
source venv/bin/activate        # Linux / Mac
venv\Scripts\activate           # Windows

# 3. Install dependencies
pip install -r requirements.txt

# 4. Launch
python main.py

GPU support: Install PyTorch with CUDA before installing other requirements. See https://pytorch.org/get-started/locally/


Launching

MethodDescription
python main.pyStandard launch with console output
run.batWindows launcher — closes the CMD window after startup
run_silent.vbsFully silent launch — no window at all (double-click)

Usage

GUI Mode

python main.py
  1. Step 1 — Drop video file(s) or select a folder
  2. Step 2 — Configure settings (format, interval, model, quality, captions)
  3. Step 3 — Click Start and monitor the log

CLI Mode

# Basic
python scripts/cli.py video.mp4

# Common options
python scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --quality --ensemble --turbo

# With captions
python scripts/cli.py video.mp4 --caption --caption-mode combined --trigger "mychar"

# Character sort
python scripts/character_sort.py /images/input --references /refs --max-characters 2

Settings Reference

Video Extractor

ParameterDefaultDescription
--format -f9:16Crop aspect ratio. 1:1 is best for LoRA; 9:16 for vertical content
--interval -i30Process every N frames. Lower = more frames, slower
--confidence -c0.5Detection threshold (0.1–0.95). Higher = fewer but cleaner detections
--padding -p500Min pixels of context around the detected subject
--model -myolov8nYOLO size: n=fast, s=balanced, m/l=accurate
--turboONBatch frame processing. Keep ON unless VRAM is very low
--batch-size4Frames per batch in turbo mode (1–16)
--ensembleOFFUse 3 AI models and vote for agreement. Slower but more accurate
--voting-threshold2How many models must agree (1–3). 3 = strictest
--qualityOFFEnable blur + noise + brightness + duplicate filtering
--captionOFFGenerate a .txt caption file per saved image
--trigger(empty)Word prepended to every caption (your LoRA keyword)
--suffix(empty)Tags appended at the end of every caption (quality tokens etc.)
--max-tags30Maximum Danbooru tags per caption
--negative-tags(none)Comma-separated tags to always exclude
--preset(none)Tagging preset: anime_character, style_lora, realistic_photo, concept_art

config.yaml — Advanced

quality:
  blur_threshold: 80.0        # Min sharpness (Laplacian variance). Higher = stricter
  brightness_min: 35          # Darkest allowed frame (0–255)
  brightness_max: 225         # Brightest allowed frame (0–255)
  duplicate_threshold: 0.90   # Similarity cutoff (0–1). Higher = keep more
  min_contrast: 20            # Minimum contrast level

captioning:
  wd14:
    model: "SmilingWolf/wd-convnext-tagger-v3"   # Auto-selected by quality preset in GUI
  florence2:
    model: "microsoft/Florence-2-base"   # "-base" (fast) or "-large" (accurate)
    task: "<MORE_DETAILED_CAPTION>"
  tags:
    min_confidence: 0.35      # Min tag confidence (0–1)
    max_tags: 30              # Max tags per caption
    trigger_word: ""          # Prepended to every caption
    caption_suffix: ""        # Appended at end (e.g. "masterpiece, best quality")

Character Sorter

ParameterDefaultDescription
--modelbuffalo_lInsightFace model. buffalo_l=accurate, buffalo_s=fast
--threshold0.45Face similarity cutoff (0–1). Lower = stricter matching
--max-characters1Limit output to 1–6 character folders. Extras go to other/
--cluster-eps0.6DBSCAN epsilon for auto-clustering unknown faces
--cluster-min2Minimum images to form a cluster. Below this goes to unknown/
--no-clusterOFFDisable auto-clustering; unmatched faces go to unknown/
--copyOFFCopy files instead of moving them
--recursiveOFFAlso scan sub-directories

Output structure:

_sorted/
├── character_name/   ← matched to reference images
├── character_01/     ← auto-clustered unknown group
├── other/            ← overflow when max_characters limit reached
├── unknown/          ← could not form a cluster
├── no_face/          ← no face detected
└── multi_face/       ← multiple faces, no clear match

Quick Presets

GoalCommand
Best LoRA datasetpython scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --ensemble --turbo --quality
Fast collectionpython scripts/cli.py video.mp4 -f 1:1 -i 50 --turbo
Maximum qualitypython scripts/cli.py video.mp4 -f 1:1 -i 10 --ensemble --voting-threshold 3 --quality
Vertical contentpython scripts/cli.py video.mp4 -f 9:16 -i 30 --turbo
With captionspython scripts/cli.py video.mp4 -f 1:1 --caption --preset anime_character --trigger "mychar" --suffix "masterpiece, best quality"

Troubleshooting

ProblemSolution
CUDA out of memoryLower --batch-size or use --no-turbo
Too few frames extractedLower --interval or --confidence
Too many false detectionsRaise --confidence, use --ensemble
Captions only contain trigger wordWD14 model failed to load — run pip install onnxruntime (or onnxruntime-gpu) and ensure you have internet access on first launch so the model can download
Captions not generatingRun pip install onnxruntime
Watermarks in outputEnable quality filter
Grainy or dark framesEnable --quality; raise quality.blur_threshold in config.yaml
InsightFace missingRun pip install insightface scikit-learn onnxruntime

Project Structure

LoRA-Harvester/
├── main.py                       # GUI entry point
├── run.bat                       # Windows launcher (CMD closes after start)
├── run_silent.vbs                # Silent launcher (no window)
├── config.yaml                   # Advanced configuration
├── requirements.txt
├── assets/
│   └── icon.png                  # Application icon
├── src/
│   ├── core/
│   │   ├── unified_processor.py   # Main video processing engine
│   │   ├── enhanced_processor.py  # Checkpoint/resume processing
│   │   ├── text_detector.py       # Subtitle & overlay detection
│   │   ├── cropper.py             # Smart aspect-ratio crop
│   │   ├── character_recognizer.py
│   │   ├── advanced_captioner.py  # WD14 / Danbooru tagger
│   │   ├── florence2_captioner.py # Natural-language captions
│   │   └── tag_autocomplete.py    # Danbooru tag loader for autocomplete
│   └── ui/
│       ├── main_window.py
│       ├── caption_studio_page.py # Generate + Edit tabs, Danbooru autocomplete
│       ├── character_sort_page.py
│       ├── tag_frequency_page.py
│       ├── translations.py
│       └── theme.py
├── scripts/
│   ├── cli.py                    # Command-line interface
│   ├── character_sort.py         # Character sorter CLI
│   ├── check_gpu.py              # GPU diagnostics
│   ├── install.bat
│   ├── install_gpu.bat
│   └── run_batch.bat
└── docs/
    ├── CHANGELOG.md
    ├── QUICKSTART.md
    ├── OPTIMIZATION.md
    ├── ENSEMBLE.md
    └── SECURITY.md

TURKCE

v4.0'da Yenilikler

  • 📝 Altyazı tespiti yeniden yazıldı — her çözünürlük ve en-boy oranında çalışır (16:9, 9:16, 480p…), tek satırlık ve üst konumlu altyazıları da bulur, sabit alt bant yerine tüm kareyi metin satırları için tarar
  • ✂️ Daha akıllı altyazı temizleme — kare doğru taraftan (üst veya alt) kırpılır; kırpma alanı overlay/altyazı bölgesinin etrafında daraltılır
  • 🖥️ Sistem monitörü düzeltildi — GPU kullanımı ve VRAM artık nvidia-smi ile cihaz genelinde okunur (torch.cuda.mem_get_info yedeği ile); eğitim alt süreçte çalışırken veya torch CPU sürümüyken bile gerçek değerler görünür
  • 🔁 --no-resume artık çalışıyor — CLI bayrağı işlemciye bağlandı
  • 🐛 Hata düzeltmeleri — çift çeviri anahtarları yüzünden tespit güveni kutusunda yanlış ipucu görünüyordu; çift _spinbox_style metodu kaldırıldı
  • 🧹 Kod temizliği — kullanılmayan 7 eski modül kaldırıldı, 16 dosyada ölü import temizlendi, cache ve bayat dosyalar silindi

v3.0'da Yenilikler

  • 🧩 Altyazi Studyosu — otomatik uretim (WD14) ve manuel duzenleme tek sayfada; yazarken canli Danbooru etiket oneri
  • 🎯 Kalite onayarlariYuksek Dogruluk / Dengeli / Yuksek Hiz sec, model ve degerler otomatik ayarlanir
  • 🔖 Tetikleyici + Sonek — hem LoRA anahtar kelimesi bastan hem kalite tokenlari sondan ayni ekranda
  • 🖼️ Florence-2 — istege bagli, tam cumleli dogal dil aciklamalar
  • ✂️ SAM2 + PySceneDetect — nesne odakli maskeleme ve kesim-seviyesinde tekrar azaltma
  • 🎨 Karanlik / Aydinlik tema + yazi tipi olcekleme + ayri Baslat/Duraklat/Atla/Durdur butonlari

Ne Ise Yarar?

LoRA-Harvester, videolardan yuksek kaliteli kareler cikarir, yuz tanima ile bunlari karaktere gore siralar ve istege bagli olarak caption uretir. Saatlerce suren manuel islemi dakikalar icinde tamamlayarak egitime hazir bir LoRA dataseti olusturur.

Ana akis:

Video(lar) → Kare cikar → AI kisi tespiti → Akilli kirp → Kalite filtresi → Caption → Dataset

Karakter Siralayici akisi:

Gorsel klasoru → Yuz tespiti → Kimlige gore eslestir/kumele → Isimli klasorlere sirala

Ozellikler

OzellikDetay
AI TespitiYOLOv8 tek model dedektor (eski 3 model ensemble yerine hizli ve modern)
Sahne TespitiIstege bagli PySceneDetect — kesimler arasi tekrar karelerini atlar
Akilli KirpmaEn-boy orani korumali kirpma, SAM2 destekli nesne maskeleme
Overlay FarkindaligiLogo/filigran tespit eder, etrafindan kirpar
Kalite FiltresiBulaniklik, gurultu, parlaklik, tekrar tespiti
Karakter SiralayiciInsightFace ile yuz tanima ve karakter siralamа
Maks KarakterCiktiyi 1-6 karakter klasoruyle sinirla; fazlasi other/'a gider
Altyazi StudyosuTek sayfada Olustur (WD14) + Duzenle (Danbooru otomatik tamamlama)
Etiketleme OnayarlariTek tikla Yuksek Dogruluk / Dengeli / Yuksek Hiz — en iyi modeli otomatik secer
Tetikleyici + SonekBas icin LoRA kelimesi ve son icin kalite tokenlari ayni yerde
Dogal DilIstege bagli Florence-2 — acik, tam cumleli aciklamalar
Etiket SikligiAltyazi klasorunu tara, etiket sayimlari uret, toplu temizle
xformersDestekleyen GPU'larda Florence-2 / SAM2 icin bellek-tasarruflu dikkat
Turbo ModToplu kare isleme ile maksimum hiz
CheckpointYariдa kesilen islemi devam ettir
Iki Dilli ArayuzTurkce / Ingilizce, tam karanlik/aydinlik tema

Kurulum

# 1. Klonla
git clone https://github.com/AllastorV/LoRA-Harvester.git
cd LoRA-Harvester

# 2. Sanal ortam olustur
python -m venv venv
source venv/bin/activate        # Linux / Mac
venv\Scripts\activate           # Windows

# 3. Bagımliliklari kur
pip install -r requirements.txt

# 4. Basla
python main.py

GPU destegi: Diger gereksinimleri kurmadan once PyTorch'u CUDA ile kur. Bkz. https://pytorch.org/get-started/locally/


Baslатma Yontemleri

YontemAciklama
python main.pyKonsol ciktisi ile standart baslатма
run.batWindows baslayicisi — uygulama actiktan sonra CMD penceresi kapanir
run_silent.vbsTamamen sessiz baslатма — hic pencere acinmaz (cift tiklа)

Kullanim

Arayuz (GUI) Modu

python main.py
  1. Adim 1 — Video dosya(lari) sürükle-birak ya da klasor sec
  2. Adim 2 — Ayarlari yapilandir (format, aralik, model, kalite, caption)
  3. Adim 3Baslat'a tikla, logu izle

Komut Satiri (CLI) Modu

# Temel kullanim
python scripts/cli.py video.mp4

# Yaygin secenekler
python scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --quality --ensemble --turbo

# Caption ile
python scripts/cli.py video.mp4 --caption --caption-mode combined --trigger "karakterim"

# Karakter siralayici
python scripts/character_sort.py /gorseller/giris --references /referanslar --max-characters 2

Ayar Referansi

Video Cikarici

ParametreVarsayilanEtkisi
--format -f9:16Kirpma en-boy orani. 1:1 LoRA icin ideal; 9:16 dikey icerik
--interval -i30Her N karede bir isle. Dusuk = daha fazla kare, yavas
--confidence -c0.5Tespit esigi (0.1-0.95). Yuksek = az ama temiz tespit
--padding -p500Nesne etrafindaki min piksel bosluk
--model -myolov8nYOLO boyutu: n=hizli, s=dengeli, m/l=dogru
--turboACIKToplu kare isleme. VRAM cok dusuk degilse acik birak
--batch-size4Turbo modunda grup basina kare sayisi (1-16)
--ensembleKAPALI3 AI modeli kullan ve oylama yap. Yavas ama cok dogru
--voting-threshold2Kac model anlasмali (1-3). 3 = en kati
--qualityKAPALIBulaniklik + gurultu + parlaklik + tekrar filtrelemeyi ac
--captionKAPALIHer gorsel icin .txt caption dosyasi olustur
--trigger(bos)Her caption'in basina eklenen kelime (LoRA anahtar kelimen)
--suffix(bos)Caption sonuna eklenen etiketler (kalite tokenlari vb.)
--max-tags30Caption basina maksimum Danbooru etiketi
--negative-tags(yok)Her zaman haric tutulacak etiketler (virgülle ayrilmis)
--preset(yok)Etiketleme onayari: anime_character, style_lora, realistic_photo, concept_art

Karakter Siralayici

ParametreVarsayilanEtkisi
--modelbuffalo_lInsightFace modeli. buffalo_l=dogru, buffalo_s=hizli
--threshold0.45Yuz benzerligi siniri (0-1). Dusuk = daha kati eslestirme
--max-characters1Ciktıyi 1-6 karakter klasoruyle sinirla. Fazlasi other/'a
--cluster-eps0.6Bilinmeyen yuzler icin DBSCAN epsilon
--cluster-min2Kume olusturmak icin gereken min gorsel sayisi
--no-clusterKAPALIOtomatik kumelemeyi kapat; eslesmeyenler unknown/'a
--copyKAPALIDosyalari tasimak yerine kopyala
--recursiveKAPALIAlt klasorleri de tara

Hizli Onayarlar

HedefKomut
En iyi LoRA datasetipython scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --ensemble --turbo --quality
Hizli toplamapython scripts/cli.py video.mp4 -f 1:1 -i 50 --turbo
Maksimum kalitepython scripts/cli.py video.mp4 -f 1:1 -i 10 --ensemble --voting-threshold 3 --quality
Dikey icerikpython scripts/cli.py video.mp4 -f 9:16 -i 30 --turbo
Caption ilepython scripts/cli.py video.mp4 -f 1:1 --caption --preset anime_character --trigger "karakterim" --suffix "masterpiece, best quality"

Sorun Giderme

SorunCozum
CUDA bellek hatasi--batch-size dusur veya --no-turbo kullan
Cok az kare cikti--interval veya --confidence degerini dusur
Cok fazla yanlis tespit--confidence yukselт, --ensemble kullan
Sadece tetikleyici kelime yaziliyorWD14 modeli yuklenmemis — pip install onnxruntime (veya onnxruntime-gpu) calistir ve ilk baslatmada internet baglantisi oldugundan emin ol
Caption olusmuyorpip install onnxruntime calistir
Ciktida filigran varKalite filtresini ac
Karlı/karanlik kareler--quality ac; config.yaml'da quality.blur_threshold degerini yukselt
InsightFace eksikpip install insightface scikit-learn onnxruntime calistir

Proje Yapisi

LoRA-Harvester/
├── main.py                       # GUI giris noktasi
├── run.bat                       # Windows baslayicisi (CMD kapanir)
├── run_silent.vbs                # Sessiz baslayici (pencere yok)
├── config.yaml                   # Gelismis yapilandirma
├── requirements.txt
├── assets/
│   └── icon.png                  # Uygulama ikonu
├── src/
│   ├── core/
│   │   ├── unified_processor.py
│   │   ├── enhanced_processor.py   # Checkpoint/devam ettirme islemcisi
│   │   ├── text_detector.py        # Altyazi ve overlay tespiti
│   │   ├── cropper.py              # Akilli en-boy oranli kirpma
│   │   ├── character_recognizer.py
│   │   ├── advanced_captioner.py   # WD14 / Danbooru etiketleyici
│   │   ├── florence2_captioner.py  # Dogal dil aciklamalar
│   │   └── tag_autocomplete.py     # Otomatik tamamlama icin etiket yukleyici
│   └── ui/
│       ├── main_window.py
│       ├── caption_studio_page.py  # Olustur + Duzenle sekmeleri
│       ├── character_sort_page.py
│       ├── tag_frequency_page.py
│       ├── translations.py
│       └── theme.py
├── scripts/
│   ├── cli.py                    # Komut satiri arayuzu
│   ├── character_sort.py         # Karakter siralayici CLI
│   ├── check_gpu.py              # GPU tani araci
│   ├── install.bat
│   ├── install_gpu.bat
│   └── run_batch.bat
└── docs/
    ├── CHANGELOG.md
    ├── QUICKSTART.md
    ├── OPTIMIZATION.md
    ├── ENSEMBLE.md
    └── SECURITY.md

GPL v3 License  |  GitHub  |  Issues

Star the repo if you find it useful!

Contributors

AllastorV

2 commits

AllastorV/LoRA-Harvester

AI-Powered Video Processing Tool for LoRA Training Dataset Creation.

1

stars

2

commits

Python

primary language

Aug 7, 2026

updated

ai
anime
computer-vision
dataset
dataset-creation
deep-learning
diffusion-models
frame-extraction
image-processing
kohya-ss
lora
lora-training
machine-learning
python
stable-diffusion
training-data
upscaling
video-processing
Browse cluster: Diffusion Models & Image Generation

README

LoRA-Harvester

LoRA-Harvester v4.0

AI-Powered Video → LoRA Training Dataset Creator

Yapay Zeka Destekli Video → LoRA Eğitim Dataseti Oluşturucu

Python PyTorch License GitHub

English | Türkçe


ENGLISH

What's New in v4.0

  • 📝 Subtitle detection rewritten — works at any resolution and aspect ratio (16:9, 9:16, 480p…), detects single-line and top-positioned subtitles, and scans the full frame for text lines instead of a fixed bottom band
  • ✂️ Smarter subtitle removal — frames are cropped from the correct side (top or bottom) and the crop shrinks around overlay/subtitle zones instead of falling back to an unconstrained crop
  • 🖥️ System monitor fixed — GPU utilization and VRAM now read device-wide via nvidia-smi (with a torch.cuda.mem_get_info fallback), so real usage shows up even while training runs in a subprocess or torch is CPU-only
  • 🔁 --no-resume actually works — the CLI flag is now wired through to the processor
  • 🐛 Bug fixes — duplicate translation keys caused the wrong tooltip on the detection-confidence spinbox; duplicate _spinbox_style method removed
  • 🧹 Codebase cleanup — 7 unused legacy modules removed, dead imports cleaned across 16 files, caches and stale files purged

What's New in v3.0

  • 🧩 Caption Studio — one page for both auto-generation (WD14) and manual editing, with live Danbooru tag autocomplete while you type
  • 🎯 Quality presets — pick High Accuracy / Balanced / High Speed; the best WD14 model, confidence, and tag count are chosen for you
  • 🔖 Trigger + Suffix — prepend a LoRA keyword and append quality tokens in the same UI
  • 🖼️ Florence-2 — optional natural-language captions for full-sentence alt-text
  • ✂️ SAM2 + PySceneDetect — subject-aware masking and cut-level deduplication
  • 🎨 Dark / Light theme + font scaling + differentiated Start/Pause/Skip/Stop buttons

What Is It?

LoRA-Harvester extracts high-quality frames from videos, sorts them by character using face recognition, and optionally generates captions — producing a clean, ready-to-train LoRA dataset in minutes instead of hours.

Main workflow:

Video(s) → Extract frames → AI detects person → Smart crop → Quality filter → Caption → Dataset

Character Sorter workflow:

Image folder → Face detection → Match / cluster by identity → Sort into named folders

Features

FeatureDetails
AI DetectionYOLOv8 single-model detector (fast, modern replacement for the old 3-model ensemble)
Scene DetectionOptional PySceneDetect integration — skips duplicate-ish content between cuts
Smart CropAspect-ratio aware crop with configurable padding, SAM2-assisted subject masking
Overlay AwarenessDetects logos/watermarks and crops around them
Quality FilterBlur, noise, brightness, and duplicate detection
Character SorterInsightFace face recognition to sort images by character identity
Max CharactersLimit output to 1–6 character folders; extras go to other/
Caption StudioSingle page merging Generate (WD14 tagging) + Edit (Danbooru autocomplete)
Tagging PresetsOne-click High Accuracy / Balanced / High Speed — auto-picks the best WD14 model
Trigger + SuffixPrepend a LoRA keyword and append quality tokens in one place
Natural-LanguageOptional Florence-2 captions for descriptive, full-sentence alt-text
Tag FrequencyScan a caption folder, count tag usage, bulk-remove unwanted tags across files
xformersOpt-in memory-efficient attention for Florence-2 / SAM2 on supported GPUs
Turbo ModeBatch frame processing for maximum throughput
CheckpointResume interrupted processing from where it stopped
Bilingual UIEnglish / Turkish interface, full dark/light theme switching

Installation

# 1. Clone the repository
git clone https://github.com/AllastorV/LoRA-Harvester.git
cd LoRA-Harvester

# 2. Create a virtual environment
python -m venv venv
source venv/bin/activate        # Linux / Mac
venv\Scripts\activate           # Windows

# 3. Install dependencies
pip install -r requirements.txt

# 4. Launch
python main.py

GPU support: Install PyTorch with CUDA before installing other requirements. See https://pytorch.org/get-started/locally/


Launching

MethodDescription
python main.pyStandard launch with console output
run.batWindows launcher — closes the CMD window after startup
run_silent.vbsFully silent launch — no window at all (double-click)

Usage

GUI Mode

python main.py
  1. Step 1 — Drop video file(s) or select a folder
  2. Step 2 — Configure settings (format, interval, model, quality, captions)
  3. Step 3 — Click Start and monitor the log

CLI Mode

# Basic
python scripts/cli.py video.mp4

# Common options
python scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --quality --ensemble --turbo

# With captions
python scripts/cli.py video.mp4 --caption --caption-mode combined --trigger "mychar"

# Character sort
python scripts/character_sort.py /images/input --references /refs --max-characters 2

Settings Reference

Video Extractor

ParameterDefaultDescription
--format -f9:16Crop aspect ratio. 1:1 is best for LoRA; 9:16 for vertical content
--interval -i30Process every N frames. Lower = more frames, slower
--confidence -c0.5Detection threshold (0.1–0.95). Higher = fewer but cleaner detections
--padding -p500Min pixels of context around the detected subject
--model -myolov8nYOLO size: n=fast, s=balanced, m/l=accurate
--turboONBatch frame processing. Keep ON unless VRAM is very low
--batch-size4Frames per batch in turbo mode (1–16)
--ensembleOFFUse 3 AI models and vote for agreement. Slower but more accurate
--voting-threshold2How many models must agree (1–3). 3 = strictest
--qualityOFFEnable blur + noise + brightness + duplicate filtering
--captionOFFGenerate a .txt caption file per saved image
--trigger(empty)Word prepended to every caption (your LoRA keyword)
--suffix(empty)Tags appended at the end of every caption (quality tokens etc.)
--max-tags30Maximum Danbooru tags per caption
--negative-tags(none)Comma-separated tags to always exclude
--preset(none)Tagging preset: anime_character, style_lora, realistic_photo, concept_art

config.yaml — Advanced

quality:
  blur_threshold: 80.0        # Min sharpness (Laplacian variance). Higher = stricter
  brightness_min: 35          # Darkest allowed frame (0–255)
  brightness_max: 225         # Brightest allowed frame (0–255)
  duplicate_threshold: 0.90   # Similarity cutoff (0–1). Higher = keep more
  min_contrast: 20            # Minimum contrast level

captioning:
  wd14:
    model: "SmilingWolf/wd-convnext-tagger-v3"   # Auto-selected by quality preset in GUI
  florence2:
    model: "microsoft/Florence-2-base"   # "-base" (fast) or "-large" (accurate)
    task: "<MORE_DETAILED_CAPTION>"
  tags:
    min_confidence: 0.35      # Min tag confidence (0–1)
    max_tags: 30              # Max tags per caption
    trigger_word: ""          # Prepended to every caption
    caption_suffix: ""        # Appended at end (e.g. "masterpiece, best quality")

Character Sorter

ParameterDefaultDescription
--modelbuffalo_lInsightFace model. buffalo_l=accurate, buffalo_s=fast
--threshold0.45Face similarity cutoff (0–1). Lower = stricter matching
--max-characters1Limit output to 1–6 character folders. Extras go to other/
--cluster-eps0.6DBSCAN epsilon for auto-clustering unknown faces
--cluster-min2Minimum images to form a cluster. Below this goes to unknown/
--no-clusterOFFDisable auto-clustering; unmatched faces go to unknown/
--copyOFFCopy files instead of moving them
--recursiveOFFAlso scan sub-directories

Output structure:

_sorted/
├── character_name/   ← matched to reference images
├── character_01/     ← auto-clustered unknown group
├── other/            ← overflow when max_characters limit reached
├── unknown/          ← could not form a cluster
├── no_face/          ← no face detected
└── multi_face/       ← multiple faces, no clear match

Quick Presets

GoalCommand
Best LoRA datasetpython scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --ensemble --turbo --quality
Fast collectionpython scripts/cli.py video.mp4 -f 1:1 -i 50 --turbo
Maximum qualitypython scripts/cli.py video.mp4 -f 1:1 -i 10 --ensemble --voting-threshold 3 --quality
Vertical contentpython scripts/cli.py video.mp4 -f 9:16 -i 30 --turbo
With captionspython scripts/cli.py video.mp4 -f 1:1 --caption --preset anime_character --trigger "mychar" --suffix "masterpiece, best quality"

Troubleshooting

ProblemSolution
CUDA out of memoryLower --batch-size or use --no-turbo
Too few frames extractedLower --interval or --confidence
Too many false detectionsRaise --confidence, use --ensemble
Captions only contain trigger wordWD14 model failed to load — run pip install onnxruntime (or onnxruntime-gpu) and ensure you have internet access on first launch so the model can download
Captions not generatingRun pip install onnxruntime
Watermarks in outputEnable quality filter
Grainy or dark framesEnable --quality; raise quality.blur_threshold in config.yaml
InsightFace missingRun pip install insightface scikit-learn onnxruntime

Project Structure

LoRA-Harvester/
├── main.py                       # GUI entry point
├── run.bat                       # Windows launcher (CMD closes after start)
├── run_silent.vbs                # Silent launcher (no window)
├── config.yaml                   # Advanced configuration
├── requirements.txt
├── assets/
│   └── icon.png                  # Application icon
├── src/
│   ├── core/
│   │   ├── unified_processor.py   # Main video processing engine
│   │   ├── enhanced_processor.py  # Checkpoint/resume processing
│   │   ├── text_detector.py       # Subtitle & overlay detection
│   │   ├── cropper.py             # Smart aspect-ratio crop
│   │   ├── character_recognizer.py
│   │   ├── advanced_captioner.py  # WD14 / Danbooru tagger
│   │   ├── florence2_captioner.py # Natural-language captions
│   │   └── tag_autocomplete.py    # Danbooru tag loader for autocomplete
│   └── ui/
│       ├── main_window.py
│       ├── caption_studio_page.py # Generate + Edit tabs, Danbooru autocomplete
│       ├── character_sort_page.py
│       ├── tag_frequency_page.py
│       ├── translations.py
│       └── theme.py
├── scripts/
│   ├── cli.py                    # Command-line interface
│   ├── character_sort.py         # Character sorter CLI
│   ├── check_gpu.py              # GPU diagnostics
│   ├── install.bat
│   ├── install_gpu.bat
│   └── run_batch.bat
└── docs/
    ├── CHANGELOG.md
    ├── QUICKSTART.md
    ├── OPTIMIZATION.md
    ├── ENSEMBLE.md
    └── SECURITY.md

TURKCE

v4.0'da Yenilikler

  • 📝 Altyazı tespiti yeniden yazıldı — her çözünürlük ve en-boy oranında çalışır (16:9, 9:16, 480p…), tek satırlık ve üst konumlu altyazıları da bulur, sabit alt bant yerine tüm kareyi metin satırları için tarar
  • ✂️ Daha akıllı altyazı temizleme — kare doğru taraftan (üst veya alt) kırpılır; kırpma alanı overlay/altyazı bölgesinin etrafında daraltılır
  • 🖥️ Sistem monitörü düzeltildi — GPU kullanımı ve VRAM artık nvidia-smi ile cihaz genelinde okunur (torch.cuda.mem_get_info yedeği ile); eğitim alt süreçte çalışırken veya torch CPU sürümüyken bile gerçek değerler görünür
  • 🔁 --no-resume artık çalışıyor — CLI bayrağı işlemciye bağlandı
  • 🐛 Hata düzeltmeleri — çift çeviri anahtarları yüzünden tespit güveni kutusunda yanlış ipucu görünüyordu; çift _spinbox_style metodu kaldırıldı
  • 🧹 Kod temizliği — kullanılmayan 7 eski modül kaldırıldı, 16 dosyada ölü import temizlendi, cache ve bayat dosyalar silindi

v3.0'da Yenilikler

  • 🧩 Altyazi Studyosu — otomatik uretim (WD14) ve manuel duzenleme tek sayfada; yazarken canli Danbooru etiket oneri
  • 🎯 Kalite onayarlariYuksek Dogruluk / Dengeli / Yuksek Hiz sec, model ve degerler otomatik ayarlanir
  • 🔖 Tetikleyici + Sonek — hem LoRA anahtar kelimesi bastan hem kalite tokenlari sondan ayni ekranda
  • 🖼️ Florence-2 — istege bagli, tam cumleli dogal dil aciklamalar
  • ✂️ SAM2 + PySceneDetect — nesne odakli maskeleme ve kesim-seviyesinde tekrar azaltma
  • 🎨 Karanlik / Aydinlik tema + yazi tipi olcekleme + ayri Baslat/Duraklat/Atla/Durdur butonlari

Ne Ise Yarar?

LoRA-Harvester, videolardan yuksek kaliteli kareler cikarir, yuz tanima ile bunlari karaktere gore siralar ve istege bagli olarak caption uretir. Saatlerce suren manuel islemi dakikalar icinde tamamlayarak egitime hazir bir LoRA dataseti olusturur.

Ana akis:

Video(lar) → Kare cikar → AI kisi tespiti → Akilli kirp → Kalite filtresi → Caption → Dataset

Karakter Siralayici akisi:

Gorsel klasoru → Yuz tespiti → Kimlige gore eslestir/kumele → Isimli klasorlere sirala

Ozellikler

OzellikDetay
AI TespitiYOLOv8 tek model dedektor (eski 3 model ensemble yerine hizli ve modern)
Sahne TespitiIstege bagli PySceneDetect — kesimler arasi tekrar karelerini atlar
Akilli KirpmaEn-boy orani korumali kirpma, SAM2 destekli nesne maskeleme
Overlay FarkindaligiLogo/filigran tespit eder, etrafindan kirpar
Kalite FiltresiBulaniklik, gurultu, parlaklik, tekrar tespiti
Karakter SiralayiciInsightFace ile yuz tanima ve karakter siralamа
Maks KarakterCiktiyi 1-6 karakter klasoruyle sinirla; fazlasi other/'a gider
Altyazi StudyosuTek sayfada Olustur (WD14) + Duzenle (Danbooru otomatik tamamlama)
Etiketleme OnayarlariTek tikla Yuksek Dogruluk / Dengeli / Yuksek Hiz — en iyi modeli otomatik secer
Tetikleyici + SonekBas icin LoRA kelimesi ve son icin kalite tokenlari ayni yerde
Dogal DilIstege bagli Florence-2 — acik, tam cumleli aciklamalar
Etiket SikligiAltyazi klasorunu tara, etiket sayimlari uret, toplu temizle
xformersDestekleyen GPU'larda Florence-2 / SAM2 icin bellek-tasarruflu dikkat
Turbo ModToplu kare isleme ile maksimum hiz
CheckpointYariдa kesilen islemi devam ettir
Iki Dilli ArayuzTurkce / Ingilizce, tam karanlik/aydinlik tema

Kurulum

# 1. Klonla
git clone https://github.com/AllastorV/LoRA-Harvester.git
cd LoRA-Harvester

# 2. Sanal ortam olustur
python -m venv venv
source venv/bin/activate        # Linux / Mac
venv\Scripts\activate           # Windows

# 3. Bagımliliklari kur
pip install -r requirements.txt

# 4. Basla
python main.py

GPU destegi: Diger gereksinimleri kurmadan once PyTorch'u CUDA ile kur. Bkz. https://pytorch.org/get-started/locally/


Baslатma Yontemleri

YontemAciklama
python main.pyKonsol ciktisi ile standart baslатма
run.batWindows baslayicisi — uygulama actiktan sonra CMD penceresi kapanir
run_silent.vbsTamamen sessiz baslатма — hic pencere acinmaz (cift tiklа)

Kullanim

Arayuz (GUI) Modu

python main.py
  1. Adim 1 — Video dosya(lari) sürükle-birak ya da klasor sec
  2. Adim 2 — Ayarlari yapilandir (format, aralik, model, kalite, caption)
  3. Adim 3Baslat'a tikla, logu izle

Komut Satiri (CLI) Modu

# Temel kullanim
python scripts/cli.py video.mp4

# Yaygin secenekler
python scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --quality --ensemble --turbo

# Caption ile
python scripts/cli.py video.mp4 --caption --caption-mode combined --trigger "karakterim"

# Karakter siralayici
python scripts/character_sort.py /gorseller/giris --references /referanslar --max-characters 2

Ayar Referansi

Video Cikarici

ParametreVarsayilanEtkisi
--format -f9:16Kirpma en-boy orani. 1:1 LoRA icin ideal; 9:16 dikey icerik
--interval -i30Her N karede bir isle. Dusuk = daha fazla kare, yavas
--confidence -c0.5Tespit esigi (0.1-0.95). Yuksek = az ama temiz tespit
--padding -p500Nesne etrafindaki min piksel bosluk
--model -myolov8nYOLO boyutu: n=hizli, s=dengeli, m/l=dogru
--turboACIKToplu kare isleme. VRAM cok dusuk degilse acik birak
--batch-size4Turbo modunda grup basina kare sayisi (1-16)
--ensembleKAPALI3 AI modeli kullan ve oylama yap. Yavas ama cok dogru
--voting-threshold2Kac model anlasмali (1-3). 3 = en kati
--qualityKAPALIBulaniklik + gurultu + parlaklik + tekrar filtrelemeyi ac
--captionKAPALIHer gorsel icin .txt caption dosyasi olustur
--trigger(bos)Her caption'in basina eklenen kelime (LoRA anahtar kelimen)
--suffix(bos)Caption sonuna eklenen etiketler (kalite tokenlari vb.)
--max-tags30Caption basina maksimum Danbooru etiketi
--negative-tags(yok)Her zaman haric tutulacak etiketler (virgülle ayrilmis)
--preset(yok)Etiketleme onayari: anime_character, style_lora, realistic_photo, concept_art

Karakter Siralayici

ParametreVarsayilanEtkisi
--modelbuffalo_lInsightFace modeli. buffalo_l=dogru, buffalo_s=hizli
--threshold0.45Yuz benzerligi siniri (0-1). Dusuk = daha kati eslestirme
--max-characters1Ciktıyi 1-6 karakter klasoruyle sinirla. Fazlasi other/'a
--cluster-eps0.6Bilinmeyen yuzler icin DBSCAN epsilon
--cluster-min2Kume olusturmak icin gereken min gorsel sayisi
--no-clusterKAPALIOtomatik kumelemeyi kapat; eslesmeyenler unknown/'a
--copyKAPALIDosyalari tasimak yerine kopyala
--recursiveKAPALIAlt klasorleri de tara

Hizli Onayarlar

HedefKomut
En iyi LoRA datasetipython scripts/cli.py video.mp4 -f 1:1 -i 15 -c 0.7 --ensemble --turbo --quality
Hizli toplamapython scripts/cli.py video.mp4 -f 1:1 -i 50 --turbo
Maksimum kalitepython scripts/cli.py video.mp4 -f 1:1 -i 10 --ensemble --voting-threshold 3 --quality
Dikey icerikpython scripts/cli.py video.mp4 -f 9:16 -i 30 --turbo
Caption ilepython scripts/cli.py video.mp4 -f 1:1 --caption --preset anime_character --trigger "karakterim" --suffix "masterpiece, best quality"

Sorun Giderme

SorunCozum
CUDA bellek hatasi--batch-size dusur veya --no-turbo kullan
Cok az kare cikti--interval veya --confidence degerini dusur
Cok fazla yanlis tespit--confidence yukselт, --ensemble kullan
Sadece tetikleyici kelime yaziliyorWD14 modeli yuklenmemis — pip install onnxruntime (veya onnxruntime-gpu) calistir ve ilk baslatmada internet baglantisi oldugundan emin ol
Caption olusmuyorpip install onnxruntime calistir
Ciktida filigran varKalite filtresini ac
Karlı/karanlik kareler--quality ac; config.yaml'da quality.blur_threshold degerini yukselt
InsightFace eksikpip install insightface scikit-learn onnxruntime calistir

Proje Yapisi

LoRA-Harvester/
├── main.py                       # GUI giris noktasi
├── run.bat                       # Windows baslayicisi (CMD kapanir)
├── run_silent.vbs                # Sessiz baslayici (pencere yok)
├── config.yaml                   # Gelismis yapilandirma
├── requirements.txt
├── assets/
│   └── icon.png                  # Uygulama ikonu
├── src/
│   ├── core/
│   │   ├── unified_processor.py
│   │   ├── enhanced_processor.py   # Checkpoint/devam ettirme islemcisi
│   │   ├── text_detector.py        # Altyazi ve overlay tespiti
│   │   ├── cropper.py              # Akilli en-boy oranli kirpma
│   │   ├── character_recognizer.py
│   │   ├── advanced_captioner.py   # WD14 / Danbooru etiketleyici
│   │   ├── florence2_captioner.py  # Dogal dil aciklamalar
│   │   └── tag_autocomplete.py     # Otomatik tamamlama icin etiket yukleyici
│   └── ui/
│       ├── main_window.py
│       ├── caption_studio_page.py  # Olustur + Duzenle sekmeleri
│       ├── character_sort_page.py
│       ├── tag_frequency_page.py
│       ├── translations.py
│       └── theme.py
├── scripts/
│   ├── cli.py                    # Komut satiri arayuzu
│   ├── character_sort.py         # Karakter siralayici CLI
│   ├── check_gpu.py              # GPU tani araci
│   ├── install.bat
│   ├── install_gpu.bat
│   └── run_batch.bat
└── docs/
    ├── CHANGELOG.md
    ├── QUICKSTART.md
    ├── OPTIMIZATION.md
    ├── ENSEMBLE.md
    └── SECURITY.md

GPL v3 License  |  GitHub  |  Issues

Star the repo if you find it useful!

Contributors

AllastorV

2 commits

Languages

Python

99.5%