Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

coach LoRA datasets toward a quality target, not just the 10-image floor

[._.]/ Adam Eivy617be8d8cf55
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 6a72049d6d..e3ab535048 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -14,6 +14,8 @@
## Changed
+- **LoRA dataset workbench now coaches toward a quality target, not just the 10-image floor** — The readiness summary only knew two states ("add more" / "ready to train"), so a barely-trainable 10-image dataset looked just as finished as a strong 25-image one. The workbench now tracks a recommended quality target (~20, sweet spot 20–30) alongside the hard `MIN_TRAINING_IMAGES` floor: the count badge turns amber while trainable-but-thin and green once it clears the target, the sub-label tells you exactly how many more captioned images are recommended, and the Train panel echoes the same nudge. A new collapsible **"Tips for a strong character dataset"** panel spells out the variety that actually matters — vary angle, framing (face close-ups + full-body), pose, expression, outfit, lighting, and background; keep it single-subject and on-model; drop blurry/near-duplicate frames. The **Generate** batch dialog now defaults to 20 images (was 12) and notes the sweet spot inline. Advisory only — the server still trains any dataset that clears the 10-image gate. (`server/lib/loraDataset.js`, `client/src/pages/LoraDatasetDetail.jsx`, `client/src/components/loraTraining/TrainingPanel.jsx`, `client/src/components/loraTraining/GenerateBatchDialog.jsx`)
+
- **LoRA dataset caption fields auto-size to their content** — Each image card's caption box was a fixed 3-row textarea, so anything longer than ~3 lines was clipped behind an internal scrollbar (and you had to drag the corner to read it). The caption field now grows to fit its full caption by default — no scrolling, no manual resize — with a comfortable minimum height for short/empty captions. Factored into a reusable `useAutoSizeTextarea` hook + `AutoSizeTextarea` component for any future auto-growing field. (`client/src/components/loraTraining/DatasetImageGrid.jsx`, `client/src/components/ui/AutoSizeTextarea.jsx`, `client/src/hooks/useAutoSizeTextarea.js`)
- **LoRA dataset workbench gains a "Re-caption all" button — re-run every caption through a new model** — "Caption all" already skips images that already have a caption (it only fills in the uncaptioned ones), so there was no one-click way to re-run a whole dataset through a freshly-picked vision model. A new **Re-caption all** button next to it sends `overwrite: true`, re-captioning every ready image with the model chosen in the caption-model picker (overwriting existing captions, including manual edits — the button's tooltip says so). The single-image "Re-caption" button already overwrote one image; this extends the same intent to the whole set. (`client/src/pages/LoraDatasetDetail.jsx`)
diff --git a/client/src/components/loraTraining/GenerateBatchDialog.jsx b/client/src/components/loraTraining/GenerateBatchDialog.jsx
index 51816f1280..cd364c677e 100644
--- a/client/src/components/loraTraining/GenerateBatchDialog.jsx
+++ b/client/src/components/loraTraining/GenerateBatchDialog.jsx
@@ -34,7 +34,10 @@ const ChipToggleList = ({ idPrefix, label, options, selected, onToggle }) => (
);
export default function GenerateBatchDialog({ dataset, expressionOptions = [], outfitOptions = [], onClose, onStarted }) {
- const [count, setCount] = useState(12);
+ // Default to the recommended quality target (~20) rather than the bare
+ // minimum so a one-click batch lands a strong dataset. See the tips block
+ // in LoraDatasetDetail for the rationale (variety > volume; ~20–30 sweet spot).
+ const [count, setCount] = useState(20);
const [expressions, setExpressions] = useState(expressionOptions);
const [outfits, setOutfits] = useState(outfitOptions);
const [submitting, setSubmitting] = useState(false);
@@ -84,6 +87,9 @@ export default function GenerateBatchDialog({ dataset, expressionOptions = [], o
onChange={(e) => setCount(Number(e.target.value))}
className="w-full"
/>
+ <p className="text-xs text-gray-500 mt-1">
+ Sweet spot ~20–30. Fewer than 10 won&apos;t train; past ~40 mostly adds time and overfitting risk.
+ </p>
</div>
{expressionOptions.length > 0 && (
<ChipToggleList
diff --git a/client/src/components/loraTraining/TrainingPanel.jsx b/client/src/components/loraTraining/TrainingPanel.jsx
index 830c2fdab5..74db9c1f26 100644
--- a/client/src/components/loraTraining/TrainingPanel.jsx
+++ b/client/src/components/loraTraining/TrainingPanel.jsx
@@ -220,7 +220,12 @@ export default function TrainingPanel({ dataset, readiness, triggerSaving, onRun
)}
</div>
<div className="flex items-center justify-between gap-2">
- <span className="text-xs text-gray-500">{disabledReason || `Trains on ${readiness?.captioned ?? 0} captioned images`}</span>
+ <span className={`text-xs ${!disabledReason && readiness?.quality === 'minimum' ? 'text-port-warning' : 'text-gray-500'}`}>
+ {disabledReason
+ || (readiness?.quality === 'minimum'
+ ? `Trains on ${readiness?.captioned ?? 0} — ${Math.max(0, (readiness?.recommended ?? 20) - (readiness?.captioned ?? 0))} more recommended`
+ : `Trains on ${readiness?.captioned ?? 0} captioned images`)}
+ </span>
<button
type="button"
onClick={start}
diff --git a/client/src/pages/LoraDatasetDetail.jsx b/client/src/pages/LoraDatasetDetail.jsx
index 7b9b946481..f97779ee1e 100644
--- a/client/src/pages/LoraDatasetDetail.jsx
+++ b/client/src/pages/LoraDatasetDetail.jsx
@@ -10,7 +10,7 @@
import { useState, useEffect, useMemo, useRef, useCallback } from 'react';
import { useParams, Link } from 'react-router-dom';
import {
- ArrowLeft, Loader2, Upload, Wand2, Scissors, Tags, RefreshCw, AlertTriangle, Images,
+ ArrowLeft, Loader2, Upload, Wand2, Scissors, Tags, RefreshCw, AlertTriangle, Images, Lightbulb,
} from 'lucide-react';
import toast from '../components/ui/Toast';
import Modal from '../components/ui/Modal';
@@ -37,6 +37,12 @@ const TRIGGER_RE = /^[a-z0-9_]{2,64}$/;
// deleted, instead of waiting on a server round-trip. Port logic changes here
// when the server helper changes.
const MIN_TRAINING_IMAGES = 10;
+const RECOMMENDED_TRAINING_IMAGES = 20;
+const qualityTier = (captioned) => {
+ if (captioned < MIN_TRAINING_IMAGES) return 'insufficient';
+ if (captioned < RECOMMENDED_TRAINING_IMAGES) return 'minimum';
+ return 'good';
+};
const captionHasTriggerWord = (caption, triggerWord) => {
const word = (triggerWord || '').trim();
const text = (caption || '').trim();
@@ -56,7 +62,9 @@ const deriveReadiness = (images, triggerWord) => {
captioned: captioned.length,
rendering: list.filter((img) => img.status === 'rendering').length,
required: MIN_TRAINING_IMAGES,
+ recommended: RECOMMENDED_TRAINING_IMAGES,
trainable: !!word && captioned.length >= MIN_TRAINING_IMAGES,
+ quality: qualityTier(captioned.length),
};
};
@@ -327,11 +335,17 @@ export default function LoraDatasetDetail() {
</div>
</div>
<div className="text-right text-sm">
- <div className={readiness.trainable ? 'text-port-success' : 'text-gray-400'}>
+ <div className={readiness.quality === 'good' ? 'text-port-success' : readiness.quality === 'minimum' ? 'text-port-warning' : 'text-gray-400'}>
{readiness.ready ?? 0} images · {readiness.captioned ?? 0}/{readiness.required ?? 10} captioned
{renderingCount ? ` · ${renderingCount} rendering` : ''}
</div>
- <div className="text-xs text-gray-500">{readiness.trainable ? 'Ready to train' : 'Add + caption more images to train'}</div>
+ <div className="text-xs text-gray-500">
+ {readiness.quality === 'good'
+ ? 'Ready to train — strong dataset'
+ : readiness.quality === 'minimum'
+ ? `Trainable now · ${Math.max(0, (readiness.recommended ?? 20) - (readiness.captioned ?? 0))} more for best quality`
+ : `Add + caption ${Math.max(0, (readiness.required ?? 10) - (readiness.captioned ?? 0))} more to train`}
+ </div>
</div>
</div>
@@ -398,6 +412,31 @@ export default function LoraDatasetDetail() {
<CaptionModelPicker onChange={onCaptionModelChange} />
</div>
+ <details className="bg-port-card border border-port-border rounded-lg text-sm">
+ <summary className="cursor-pointer select-none px-3 py-2 flex items-center gap-2 text-gray-300 hover:text-white">
+ <Lightbulb className="w-4 h-4 text-port-warning shrink-0" />
+ <span className="font-medium">Tips for a strong character dataset</span>
+ <span className="text-xs text-gray-500">
+ target ~{RECOMMENDED_TRAINING_IMAGES}–30 images · {MIN_TRAINING_IMAGES} minimum
+ </span>
+ </summary>
+ <div className="px-3 pb-3 pt-1 text-xs text-gray-400 space-y-2 border-t border-port-border/60">
+ <p>
+ Quality beats quantity. {MIN_TRAINING_IMAGES} images is the floor; ~{RECOMMENDED_TRAINING_IMAGES}–30 sharp,
+ varied shots is the sweet spot. Past ~50 you mostly add training time and overfitting risk —
+ near-duplicate frames teach the model to memorize a pose instead of learning the character.
+ </p>
+ <ul className="list-disc pl-4 space-y-1">
+ <li><span className="text-gray-300">Vary the angle</span> — front, three-quarter, profile, and a back view.</li>
+ <li><span className="text-gray-300">Vary the framing</span> — mix tight face close-ups (for likeness) with mid and full-body shots (for proportions).</li>
+ <li><span className="text-gray-300">Vary pose &amp; expression</span> — standing, sitting, action; neutral, smiling, intense.</li>
+ <li><span className="text-gray-300">Vary outfit, lighting &amp; background</span> — so the LoRA learns the character, not one costume, key light, or backdrop.</li>
+ <li><span className="text-gray-300">Keep it single-subject and on-model</span> — one clearly-visible character per image, consistent identity, no clutter or other people.</li>
+ <li><span className="text-gray-300">Drop the weak ones</span> — blurry, occluded, or off-model frames hurt more than they help; avoid near-duplicates.</li>
+ </ul>
+ </div>
+ </details>
+
<div className="grid grid-cols-1 lg:grid-cols-[1fr_320px] gap-4 items-start">
<DatasetImageGrid
dataset={dataset}
diff --git a/server/lib/README.md b/server/lib/README.md
index ce2c107f00..e98501f3a7 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -181,7 +181,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `localLlmCatalog.js` | Curated cross-backend (Ollama↔LM Studio) local-LLM catalog + install-id mapping for the migrate flow. Pure. |
| `localLlmDisk.js` | Pure on-disk reasoning for the migrate "copy GGUF locally instead of re-downloading" fast-path (Ollama manifest/blob parsing, LM Studio path layout, MLX/projector/shard detection). |
| `localModelHeuristics.js` | Capability heuristics for untyped local (Ollama/LM Studio) models. `isEmbeddingModel`/`isGenerationModel` (so a generation/fallback run never picks an embedding model like `nomic-embed-text`); `isVisionModel(model)` (string id or model card — prefers explicit `type:'vlm'`/`capabilities:['vision']` metadata, falls back to id regex; used by the LoRA captioner); `recommendEditorialModel(models)` ranks installed models for editorial review/editing. Pure. Mirror `isEmbeddingModel`/`isVisionModel` in `client/src/utils/providers.js`. |
-| `loraDataset.js` | Pure helpers for character LoRA training datasets (`data/lora-datasets/`): `sanitizeLoraDataset` (collectionStore sanitizer), `deriveTriggerWord` (name → single-token slug with collision suffix), `prefixCaption` (idempotent trigger-word prefixing), `buildVariationMatrix` (deterministic view/pose/expression/outfit tuples for batch generation), `computeDatasetReadiness` (trainable gate: ≥`MIN_TRAINING_IMAGES` ready+captioned images). Prompt building + I/O live in `services/loraDatasetGenerate.js` / `services/loraDatasets.js`. |
+| `loraDataset.js` | Pure helpers for character LoRA training datasets (`data/lora-datasets/`): `sanitizeLoraDataset` (collectionStore sanitizer), `deriveTriggerWord` (name → single-token slug with collision suffix), `prefixCaption` (idempotent trigger-word prefixing), `buildVariationMatrix` (deterministic view/pose/expression/outfit tuples for batch generation), `computeDatasetReadiness` (trainable gate: ≥`MIN_TRAINING_IMAGES` ready+captioned images, plus an advisory `recommended`/`quality` tier via `datasetQualityTier` nudging toward `RECOMMENDED_TRAINING_IMAGES`). Prompt building + I/O live in `services/loraDatasetGenerate.js` / `services/loraDatasets.js`. |
| `issueLength.js` | Per-issue size targets fed into text stages. |
| `mediaItemKey.js` | `<kind>:<ref>` key vocabulary for media items. |
| `navManifest.js` | Single source of truth for nav (`⌘K` palette + voice). Add an entry when you add a page. |
diff --git a/server/lib/loraDataset.js b/server/lib/loraDataset.js
index 644cc01060..5b1ec90f86 100644
--- a/server/lib/loraDataset.js
+++ b/server/lib/loraDataset.js
@@ -18,6 +18,14 @@ export const LORA_DATASET_SCHEMA_VERSION = 1;
// ~10 images a character LoRA badly overfits the few poses it has seen.
export const MIN_TRAINING_IMAGES = 10;
+// Quality target a character LoRA wants to hit for a reliable likeness across
+// poses/framing. 10 is *trainable* but thin; ~20–30 varied shots is the sweet
+// spot. Past ~50 you mostly add training time and overfitting risk (near-
+// duplicate frames teach the net to memorize, not generalize), so the UI
+// nudges toward the target rather than "more is always better".
+export const RECOMMENDED_TRAINING_IMAGES = 20;
+export const TRAINING_IMAGE_SWEET_SPOT_MAX = 30;
+
export const DATASET_IMAGE_SOURCES = Object.freeze(['generated', 'upload', 'refsheet-slice', 'gallery']);
export const DATASET_IMAGE_STATUSES = Object.freeze(['rendering', 'ready', 'failed']);
export const DATASET_STATUSES = Object.freeze(['draft', 'training', 'trained']);
@@ -224,10 +232,26 @@ export function captionHasTriggerWord(caption, triggerWord) {
return new RegExp(`(?:^|[^a-z0-9_])${escapeRe(word)}(?:[^a-z0-9_]|$)`, 'i').test(text);
}
+/**
+ * Bucket a captioned-image count into a quality tier. Pure — shared by the
+ * server readiness helper and mirrored client-side so the UI advisory and the
+ * authoritative gate agree on wording:
+ * 'insufficient' — below the hard minimum, not trainable
+ * 'minimum' — trainable but thin; more variety recommended
+ * 'good' — at/above the recommended quality target
+ */
+export function datasetQualityTier(captioned) {
+ if (captioned < MIN_TRAINING_IMAGES) return 'insufficient';
+ if (captioned < RECOMMENDED_TRAINING_IMAGES) return 'minimum';
+ return 'good';
+}
+
/**
* Compute dataset readiness for training. Pure — callers pass the sanitized
* record. `trainable` requires a trigger word plus MIN_TRAINING_IMAGES
* images that are status 'ready' AND carry a caption with the trigger token.
+ * `recommended`/`quality` are advisory only — they nudge toward a stronger
+ * dataset without blocking a thin-but-valid run.
*/
export function computeDatasetReadiness(dataset) {
const images = Array.isArray(dataset?.images) ? dataset.images : [];
@@ -240,6 +264,8 @@ export function computeDatasetReadiness(dataset) {
captioned: captioned.length,
rendering: images.filter((img) => img.status === 'rendering').length,
required: MIN_TRAINING_IMAGES,
+ recommended: RECOMMENDED_TRAINING_IMAGES,
trainable: !!triggerWord && captioned.length >= MIN_TRAINING_IMAGES,
+ quality: datasetQualityTier(captioned.length),
};
}
diff --git a/server/lib/loraDataset.test.js b/server/lib/loraDataset.test.js
index a7ca925e68..677e01eddf 100644
--- a/server/lib/loraDataset.test.js
+++ b/server/lib/loraDataset.test.js
@@ -3,9 +3,11 @@ import {
buildVariationMatrix,
captionHasTriggerWord,
computeDatasetReadiness,
+ datasetQualityTier,
deriveTriggerWord,
isValidTriggerWord,
MIN_TRAINING_IMAGES,
+ RECOMMENDED_TRAINING_IMAGES,
prefixCaption,
sanitizeDatasetImage,
sanitizeLoraDataset,
@@ -190,6 +192,28 @@ describe('computeDatasetReadiness', () => {
expect(computeDatasetReadiness({ triggerWord: '', images }).trainable).toBe(false);
});
+ it('reports the recommended target and an advisory quality tier', () => {
+ const mk = (n) => computeDatasetReadiness({
+ triggerWord: 'kessa',
+ images: Array.from({ length: n }, (_, i) => img({ id: `i${i}` })),
+ });
+ expect(mk(MIN_TRAINING_IMAGES - 1)).toMatchObject({ quality: 'insufficient', trainable: false });
+ // Trainable but below the recommended target → 'minimum' (still trainable).
+ expect(mk(MIN_TRAINING_IMAGES)).toMatchObject({
+ quality: 'minimum', trainable: true, recommended: RECOMMENDED_TRAINING_IMAGES,
+ });
+ expect(mk(RECOMMENDED_TRAINING_IMAGES)).toMatchObject({ quality: 'good', trainable: true });
+ });
+
+ it('datasetQualityTier brackets on the min and recommended thresholds', () => {
+ expect(datasetQualityTier(0)).toBe('insufficient');
+ expect(datasetQualityTier(MIN_TRAINING_IMAGES - 1)).toBe('insufficient');
+ expect(datasetQualityTier(MIN_TRAINING_IMAGES)).toBe('minimum');
+ expect(datasetQualityTier(RECOMMENDED_TRAINING_IMAGES - 1)).toBe('minimum');
+ expect(datasetQualityTier(RECOMMENDED_TRAINING_IMAGES)).toBe('good');
+ expect(datasetQualityTier(RECOMMENDED_TRAINING_IMAGES + 50)).toBe('good');
+ });
+
it('matches trigger word case-insensitively', () => {
const out = computeDatasetReadiness({
triggerWord: 'kessa',