A neural network trainer (for weebs)
Project description
neurosis
a neural network trainer for weebs diffusion models.
OwO what's this?
I got sick and tired of trying to trace execution through the arcane codepaths of existing Stable Diffusion trainers, so I wrote my own. This is based off the modeling/training code from @Stability-AI/generative-models, with significant modification for usability and readability.
Features
Major changes from generative-models
include:
- Architectural changes:
- Migration to full PyTorch Lightning
- LightningCLI trainer interface and configuration management (config file format is largely the same as
generative-models
, but with some minor differences in keywords) - Refactoring of some of the configuration code and model subclassing
- "oops, all wandb" approach to logging (with some TensorBoard support as well)
- Trainer changes:
- Use of PyTorch Lightning's
Trainer
class for training - Support for multiple GPUs (and multiple nodes, if you're into that)
- Support for individual learning rates for the UNet and for each TE module
- VAE training support! (kinda! discriminators are iffy but it works mostly)
- Use of PyTorch Lightning's
- Module changes:
- Rework of the
ImageLogger
to... sorta kinda work? - Adding support for
Adafactor
scheduler as well as the usual BitsAndBytes etc. ones - hey look tag frequency based loss scaling wonder where we got that one from :eyes:
- Cleanup and refactoring of most modules to make them more readable and easier to trace execution
- Probably more duplicated code than there really should be but here we are in this hell timeline
- A huge pile of small changes too numerous to mention
- Rework of the
- Dataset handling:
- Support for Huggingface datasets (kinda! you're on your own but it should work if the keys match)
- Shiny new ImageFolder datasets in "square", "square with captions", and "aspect-bucketed with captions" flavors
- Support for custom datasets (see
neurosis/dataset/
for examples) - Funny hybrid mongo+s3 dataset we're using for large-scale training (stop judging me, it works)
- Support for custom data transform functions injected into the dataset pipeline[^1]
[^1]: completely untested and not entirely pushed to public yet sry
Installation
OK so first of all:
- Do Not.
if you REALLY must, here:
git clone https://github.com/neggles/neurosis.git neurosis
cd neurosis
python3.10 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip setuptools wheel setuptools-scm
python -m pip install -e '.[all]'
There is a docker container in GitHub packages, if you're feeling masochistic today.
Will also be throwing up Kubeflow manifest examples at some point (needs more testing)
Usage
I am once again asking,
- Please, please just Do Not
but if the idea of arguing with my code and trying to figure shit out from incomplete outdated configuration templates sounds attractive to you, by all means:
python -m neurosis.trainer.cli --help
If you need more assistance than that, this code is probably not ready for you to use yet.
If you open an issue without providing liberal amounts of detail, logs, exactly what you tried, and exactly how it broke, you're going to get WONTFIX'd for the time being.
This will change as/if/when the code gets a bit more stable and usable.
License
My own code is GPLv3, see LICENSE.md
A significant amount of code is copied from from @Stability-AI/generative-models,which is MIT licensed and has been relicensed here under GPLv3 due to the extensive modifications.
Some code carries its own licenses (most notably LPIPS and Adafactor), see the appropriate SPDX identifiers and LICENSE files in the relevant files' directories.
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
File details
Details for the file neurosis-0.1.1.tar.gz
.
File metadata
- Download URL: neurosis-0.1.1.tar.gz
- Upload date:
- Size: 209.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96d772f6b4eb0a6cd9575b8fc0d902a27430d096f1640b0209ceb92ecb9a8286 |
|
MD5 | 440bd1251e44365b16c378bbd5707cc8 |
|
BLAKE2b-256 | 85b28acaf9fb0aa6d99e176f18b583bb46ac942d82e029f9d61964e956e77f20 |
File details
Details for the file neurosis-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: neurosis-0.1.1-py3-none-any.whl
- Upload date:
- Size: 252.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 272a6365343a63e2ab1ecb7ad1987f29660a64208fd9629f3fa541def82c86cf |
|
MD5 | a0ff9575f710eed57bd9a0d30c68c80a |
|
BLAKE2b-256 | e32024b9a5f3f44a1b449a547ecd7d89aa1ea4c99a1e0552a9ca3e80c68794dc |