Skip to main content

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)
  • 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 pipeline[^1]

[^1]: completely untested and not entirely pushed to public yet sry

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neurosis-0.1.3.tar.gz (209.2 kB view details)

Uploaded Source

Built Distribution

neurosis-0.1.3-py3-none-any.whl (253.1 kB view details)

Uploaded Python 3

File details

Details for the file neurosis-0.1.3.tar.gz.

File metadata

  • Download URL: neurosis-0.1.3.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

Hashes for neurosis-0.1.3.tar.gz
Algorithm Hash digest
SHA256 15e2bae0c78e0bda63d1fd3bb5ddd2c6331ef8bb8d6e8fe76eba1be045d585d9
MD5 c7c247a6ac64c79e87794ea5d75b1d10
BLAKE2b-256 196d3861d11cf71952a1d83e7ed9ac37408e06017c20e9bfc262b43880192099

See more details on using hashes here.

File details

Details for the file neurosis-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: neurosis-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 253.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for neurosis-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ee100f3afee731eb49374f09cceb4b2e48c50b500474d860440a94b025cc8113
MD5 172b0a14179f0b857dfa2b9cde547999
BLAKE2b-256 0ccb7b26f36fdf996d30d4266019d74c668afa1cf1ee057b3fb4e939ee6c4bea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page