MCPcopy Index your code
hub / github.com/KohakuBlueleaf/HyperKohaku

github.com/KohakuBlueleaf/HyperKohaku @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
94 symbols 344 edges 10 files 9 documented · 10% updated 2y ago★ 13813 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

HyperKohaku

A diffusers based implementation of HyperDreamBooth

the code is based on the HyperDreamBooth implementation in the LyCORIS project.

TODOs

If you have any idea on these todos, just open issues or PRs. Thx!

  • Implement in-run validation
  • Implement section 4
  • Implement better dreambooth training (like mask the face during training)
  • Implement a more general hypernetwork (Already in LyCORIS)

HyperDreamBooth

This section is a brief introduction of HyperDreamBooth, I will split hyperdreambooth into 4 sections. And this projection will have 4 corresponding scripts

Section 1: Pre Optimize

Before we start to train the hypernetwork, we should train the lora(lilora) on each identites(instance) first. In this implementation, we took a batch of instances and then do a inner training loop to get the pre optimized weights.

Section 2: train the hypernetwork

Just train it. send the image into hypernetwork, get the weights, apply to unet. Calc the loss based on diffusion loss and weight loss.

Section 3: gen the weight

Use the image of the identity you want to train on, generate the weight from hypernetwork.

Section 4: further finetuning

resume from the generated weight, do a few step training (for about 20~50step)

Core symbols most depended-on inside this repo

enable_gradient_checkpointing
called by 4
modules/hypernet.py
compute_text_embeddings
called by 3
train_preoptimized_liloras.py
update_weight
called by 3
modules/lightlora.py
set_lilora
called by 3
modules/hypernet.py
default
called by 3
modules/utils/__init__.py
tokenize_prompt
called by 2
train_preoptimized_liloras.py
encode_prompt
called by 2
train_preoptimized_liloras.py
tokenize_prompt
called by 2
train_hyperdreambooth.py

Shape

Method 51
Function 27
Class 16

Languages

Python100%

Modules by API surface

modules/hypernet.py28 symbols
train_preoptimized_liloras.py18 symbols
train_hyperdreambooth.py18 symbols
modules/lightlora.py13 symbols
modules/attention.py13 symbols
hypernetwork_gen_weight.py3 symbols
modules/utils/__init__.py1 symbols

For agents

$ claude mcp add HyperKohaku \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact