Merge branch 'phase/61-portrait-loras-embeds'

This commit is contained in:
Leonid Pershin
2026-08-20 15:14:45 +03:00
18 changed files with 450 additions and 73 deletions
+1
View File
@@ -10,6 +10,7 @@
| [Что нового](whats-new.md) | 54 |
| [Состояние экрана](view-state.md) | 55 |
| [Модели портретов](portrait-models.md) | 60 |
| [LoRA и embeddings](portrait-loras-embeds.md) | 61 |
Люди: [`../02-people/people.md`](../02-people/people.md). Штат: [`../03-staffing/staffing.md`](../03-staffing/staffing.md).
Расписание: [`../04-schedule/schedule.md`](../04-schedule/schedule.md). Присутствие: [`../05-ai/ai.md`](../05-ai/ai.md).
@@ -0,0 +1,27 @@
Часть [Вне очереди](README.md). Соседей по папке не читать, если задача не про них.
# LoRA и embeddings на каждом слое
### Зачем
Портрет собирается из модели, пресета и типа кадра. LoRA и textual inversion должны
включаться на любом из этих слоёв, а не только в дефолтах модели.
### Было / Стало / Почему
**Было.** Positive/negative LoRA только на модели и в оверрайде пресета. В Swarm уходила
одна строка `name,weight,…`. Embeddings из Swarm в пикере не было. Теги `<lora:>` в
негативном промпте Swarm не загружают сеть.
**Стало.** LoRA и embeddings (name + weight) на модели, на пресете (добавка) и на каждом
виде кадра. Слои **склеиваются**: модель → пресет → кадр. Все LoRA уходят в
`loras` + `loraweights`. Embeddings — в промпт как `<embed:name>` (вес ≠ 1:
`<embed:name:w>`). Discovery отдаёт список embeddings. По умолчанию списки пустые.
**Почему.** Swarm грузит LoRA параметрами, embeddings — текстом промпта. Кадр (аватар vs
полный рост) может нуждаться в своей LoRA, не меняя модель.
### Что не входит
Whitelist embeddings как у чекпоинтов. ControlNet. Включение PDXL embeds по умолчанию.
Бамп сокета.
@@ -0,0 +1,39 @@
# Фаза 61. LoRA и embeddings
## Зависимости
Фаза 60 (каталог моделей и слои промпта). Ветка от `phase/60-portrait-models`.
## Зачем
LoRA и embeddings можно поставить на модель, на пресет и на тип кадра. Swarm получает
их тем каналом, который реально загружает сеть.
## Задачи
- [x] Discovery: список `embeddings` из Swarm (`models.Embedding`)
- [x] Списки LoRA и embeddings (name + weight) на модели, пресете и avatar/custom/full.
Склейка модель → пресет → кадр. Пустые списки в шаблоне
- [x] Генерация: все LoRA в `loras` и `loraweights`; embeddings в positive/negative как
`<embed:name>`. Не писать `<lora:>` в промпт
- [x] UI: комбобоксы из discovery на модели, в спойлере пресета и в секции кадра. `t(...)`
- [x] HTTP в [`protocol.md`](../../protocol.md), сокет не бампить
## Тесты, без которых фаза не закрыта
- [x] Discovery парсит embeddings; офлайн — пустой список
- [x] Склейка LoRA/embed: модель + пресет + kind
- [x] Промпт содержит `<embed:…>` и не содержит `<lora:`
- [x] Generate шлёт `loras` и `loraweights` раздельно
- [x] Диалог: поля embeddings у модели и у вида кадра
## Критерий готовности
- В диалоге создания школы LoRA и embedding можно добавить на модель, в оверрайд пресета
и на аватар / свой промпт / полный рост
- Список имён — из Swarm, как у LoRA сейчас
- «Показать промпт» показывает embed-теги; LoRA в тексте промпта нет
## Стоп
Не бампить сокет. Не включать конкретные embeds в дефолтный шаблон. Не трогать ControlNet.
+1 -1
View File
@@ -20,4 +20,4 @@
| [54. Что нового](54-whats-new.md) | ✅ | После входа — окно коммитов с прошлого визита |
| [55. Состояние экрана](55-view-state.md) | ✅ | F5 и переходы не сбрасывают школу, вкладки и фильтры |
| [60. Модели портретов](60-portrait-models.md) | ✅ | Каталог моделей Swarm ∩ конфиг, слои промпта, спойлер оверрайдов |
| [61. LoRA и embeddings](61-portrait-loras-embeds.md) | 🔄 | LoRA и embeddings на модели, пресете и типе кадра |
| [61. LoRA и embeddings](61-portrait-loras-embeds.md) | | LoRA и embeddings на модели, пресете и типе кадра |
+13 -9
View File
@@ -507,9 +507,10 @@ land under `saves/{id}.portraits/` and survive until the school is deleted.
Returns the positive and negative prompts SwarmUI would receive, without generating an image.
Same `kind` query as GET portrait. For `kind=custom`, optional query `promptExtra` is appended after
the shot type; when omitted, the last saved custom prompt is used if one exists. Unknown school
is `404` `unknown-school`; unknown person is `404` `unknown-person`. Invalid `kind` is
`400` `invalid-query`; custom without a usable prompt is `400` `invalid-body`.
the shot type; when omitted, the last saved custom prompt is used if one exists. Configured
embeddings appear as `<embed:name>` (weight ≠ 1: `<embed:name:w>`); LoRA is not written into the
prompt. Unknown school is `404` `unknown-school`; unknown person is `404` `unknown-person`. Invalid
`kind` is `400` `invalid-query`; custom without a usable prompt is `400` `invalid-body`.
```json
{
@@ -528,8 +529,10 @@ so the client can disable generate buttons and show reachability without trying
### `GET /api/settings/swarmui`
Returns the **default** SwarmUI template (`swarmui.json`): a `models` catalog (id, default
generation knobs, usually empty base positive/negative), named presets (model id, `style`, extra
negative, optional generation overrides, per-kind size/`shotType`), `activePresetId` and `ageRules`.
generation knobs, usually empty base positive/negative, LoRA and embedding lists), named presets
(model id, `style`, extra negative, optional generation overrides, per-kind size/`shotType`, LoRA
and embedding lists), `activePresetId` and `ageRules`. LoRA and embeddings on the model, preset and
shot kind concatenate at generate time.
The model picker in the UI is Swarm's list intersected with `models`. A new school copies this into
its save as `portraitSettings`. Living schools generate from that copy, not from this file. Older
saves without `models` lift on load (`positive``style`, kind `positive``shotType`).
@@ -542,10 +545,11 @@ return `400` `invalid-body`. Already-created schools keep the copy they were cre
### `GET /api/settings/swarmui/discovery`
When SwarmUI is configured and reachable, proxies `ListT2IParams` and returns
`{ connected, models, loras, samplers, schedulers }` for the settings UI. The client hides Swarm
models that are missing from the template catalog. When SwarmUI is off or unreachable, `connected`
is false and the lists are empty; the picker then shows the catalog ids so fields can be filled
manually.
`{ connected, models, loras, embeddings, samplers, schedulers }` for the settings UI. LoRA and
embeddings can be set on the model, the preset, and each shot kind; layers concatenate. The client
hides Swarm models that are missing from the template catalog. When SwarmUI is off or unreachable,
`connected` is false and the lists are empty; the picker then shows the catalog ids so fields can
be filled manually.
### `GET /api/schools/{id}/dress-rules`