Skip to main content

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)
  • 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
  • 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 pipeline1

Installation

OK so first of all:

  1. 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,

  1. 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.

  1. completely untested and not entirely pushed to public yet sry ↩

Metadata

Release files for neurosis 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neurosis 0.1.3
File Size Uploaded
neurosis-0.1.3.tar.gz 209.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for neurosis 0.1.3
File Interpreter ABI Platform
neurosis-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 462.3 kB

Release files / neurosis-0.1.3.tar.gz

Download URL neurosis-0.1.3.tar.gz
Size 209.2 kB
Tags Source
SHA-256 checksum
How to use checksums
15e2bae0c78e0bda63d1fd3bb5ddd2c6331ef8bb8d6e8fe76eba1be045d585d9
BLAKE2b-256 checksum
How to use checksums
196d3861d11cf71952a1d83e7ed9ac37408e06017c20e9bfc262b43880192099
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / neurosis-0.1.3-py3-none-any.whl

Download URL neurosis-0.1.3-py3-none-any.whl
Size 253.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee100f3afee731eb49374f09cceb4b2e48c50b500474d860440a94b025cc8113
BLAKE2b-256 checksum
How to use checksums
0ccb7b26f36fdf996d30d4266019d74c668afa1cf1ee057b3fb4e939ee6c4bea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page