naifu


Namenaifu JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/mikubill/naifu-diffusion
Summarynaifu is designed for training generative models with various configurations and features.
upload_time2024-02-17 15:51:44
maintainer
docs_urlNone
authorMikubill
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Naifu

naifu-diffusion (or naifu) is designed for training generative models with various configurations and features. The code in the main branch of this repository is under development and subject to change as new features are added.

Other branches in the repository include:
* sgm - Uses the [sgm](https://github.com/Stability-AI/generative-models) to train SDXL models. 
* main-archived - Contains the original naifu-diffusion code for training Stable Diffusion 1.x models.

## Installation

To install the necessary dependencies, simply run:

```bash
git clone https://github.com/mikubill/naifu-diffusion
pip install -r requirements.txt
```

## Usage

You can train the image model using different configurations by running the `trainer.py` script with the appropriate configuration file.

```bash
python trainer.py --config config/<config_file>
python trainer.py config/<config_file>
```

Replace `<config_file>` with one of the available configuration files listed below.

## Available Configurations

Choose the appropriate configuration file based on training objectives and environment.

Train SDXL (Stable Diffusion XL) model
```bash
# stabilityai/stable-diffusion-xl-base-1.0
python trainer.py config/train.yaml
```

Train SDXL refiner (Stable Diffusion XL refiner) model
```bash
# stabilityai/stable-diffusion-xl-refiner-1.0
python trainer.py config/train_refiner.yaml
```

Train original Stable Diffusion 1.4 or 1.5 model
```bash
# runwayml/stable-diffusion-v1-5
# Note: will save in diffusers format
python trainer.py config/train_sd15.yaml
```

Train SDXL model with diffusers backbone
```bash
# stabilityai/stable-diffusion-xl-base-1.0
# Note: will save in diffusers format
python trainer.py config/train_diffusers.yaml
```

Train SDXL model with LyCORIS.
```bash
# Based on the work available at KohakuBlueleaf/LyCORIS
pip install lycoris_lora toml
python trainer.py config/train_lycoris.yaml
```

Use fairscale strategy for distributed data parallel sharded training
```bash
pip install fairscale
python trainer.py config/train_fairscale.yaml
```

Train SDXL model with Diffusion DPO  
Paper: Diffusion Model Alignment Using Direct Preference Optimization ([arxiv:2311.12908](https://arxiv.org/abs/2311.12908))
```bash
# dataset: yuvalkirstain/pickapic_v2
# Be careful tuning the resolution and dpo_betas!
# will save in diffusers format
python trainer.py config/train_dpo_hfdataset.yaml
```

Train Pixart-Alpha model  
Paper: Fast Training of Diffusion Transformer for Photorealistic Text-to-Image Synthesis ([arxiv:2310.00426](https://arxiv.org/abs/2310.00426))
```bash
# PixArt-alpha/PixArt-XL-2-1024-MS
python trainer.py config/train_pixart.yaml
```

Train SDXL-LCM model  
Paper: Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference ([arxiv:2310.04378](https://arxiv.org/abs/2310.04378))
```bash
# PixArt-alpha/PixArt-XL-2-1024-MS
python trainer.py config/train_lcm.yaml
```

## Preparing Datasets

Each configuration file may have different dataset requirements. Make sure to check the specific configuration file for any dataset specifications or requirements.

You can use your dataset directly for training. Simply point the configuration file to the location of your dataset. If you want to reduce the VRAM usage during training, you can encode your dataset to latents using the `encode_latents.py` script.

```bash
# prepare images in input_path
python encode_latents.py -i <input_path> -o <encoded_path>
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mikubill/naifu-diffusion",
    "name": "naifu",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mikubill",
    "author_email": "31246794+Mikubill@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/69/c0/d598ff6ff7abde769e52863f4db48c05316b68dde57da59493dd690c6547/naifu-0.1.3.tar.gz",
    "platform": null,
    "description": "# Naifu\n\nnaifu-diffusion (or naifu) is designed for training generative models with various configurations and features. The code in the main branch of this repository is under development and subject to change as new features are added.\n\nOther branches in the repository include:\n* sgm - Uses the [sgm](https://github.com/Stability-AI/generative-models) to train SDXL models. \n* main-archived - Contains the original naifu-diffusion code for training Stable Diffusion 1.x models.\n\n## Installation\n\nTo install the necessary dependencies, simply run:\n\n```bash\ngit clone https://github.com/mikubill/naifu-diffusion\npip install -r requirements.txt\n```\n\n## Usage\n\nYou can train the image model using different configurations by running the `trainer.py` script with the appropriate configuration file.\n\n```bash\npython trainer.py --config config/<config_file>\npython trainer.py config/<config_file>\n```\n\nReplace `<config_file>` with one of the available configuration files listed below.\n\n## Available Configurations\n\nChoose the appropriate configuration file based on training objectives and environment.\n\nTrain SDXL (Stable Diffusion XL) model\n```bash\n# stabilityai/stable-diffusion-xl-base-1.0\npython trainer.py config/train.yaml\n```\n\nTrain SDXL refiner (Stable Diffusion XL refiner) model\n```bash\n# stabilityai/stable-diffusion-xl-refiner-1.0\npython trainer.py config/train_refiner.yaml\n```\n\nTrain original Stable Diffusion 1.4 or 1.5 model\n```bash\n# runwayml/stable-diffusion-v1-5\n# Note: will save in diffusers format\npython trainer.py config/train_sd15.yaml\n```\n\nTrain SDXL model with diffusers backbone\n```bash\n# stabilityai/stable-diffusion-xl-base-1.0\n# Note: will save in diffusers format\npython trainer.py config/train_diffusers.yaml\n```\n\nTrain SDXL model with LyCORIS.\n```bash\n# Based on the work available at KohakuBlueleaf/LyCORIS\npip install lycoris_lora toml\npython trainer.py config/train_lycoris.yaml\n```\n\nUse fairscale strategy for distributed data parallel sharded training\n```bash\npip install fairscale\npython trainer.py config/train_fairscale.yaml\n```\n\nTrain SDXL model with Diffusion DPO  \nPaper: Diffusion Model Alignment Using Direct Preference Optimization ([arxiv:2311.12908](https://arxiv.org/abs/2311.12908))\n```bash\n# dataset: yuvalkirstain/pickapic_v2\n# Be careful tuning the resolution and dpo_betas!\n# will save in diffusers format\npython trainer.py config/train_dpo_hfdataset.yaml\n```\n\nTrain Pixart-Alpha model  \nPaper: Fast Training of Diffusion Transformer for Photorealistic Text-to-Image Synthesis ([arxiv:2310.00426](https://arxiv.org/abs/2310.00426))\n```bash\n# PixArt-alpha/PixArt-XL-2-1024-MS\npython trainer.py config/train_pixart.yaml\n```\n\nTrain SDXL-LCM model  \nPaper: Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference ([arxiv:2310.04378](https://arxiv.org/abs/2310.04378))\n```bash\n# PixArt-alpha/PixArt-XL-2-1024-MS\npython trainer.py config/train_lcm.yaml\n```\n\n## Preparing Datasets\n\nEach configuration file may have different dataset requirements. Make sure to check the specific configuration file for any dataset specifications or requirements.\n\nYou can use your dataset directly for training. Simply point the configuration file to the location of your dataset. If you want to reduce the VRAM usage during training, you can encode your dataset to latents using the `encode_latents.py` script.\n\n```bash\n# prepare images in input_path\npython encode_latents.py -i <input_path> -o <encoded_path>\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "naifu is designed for training generative models with various configurations and features.",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/mikubill/naifu-diffusion"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f1d7848386dc00def2745cd45295c33e1d55320394a448627dcbd656dea883a1",
                "md5": "26aed6a68df9fcfb7db5547c707666d1",
                "sha256": "fe8cf12d7076faa7ae10fc73a053c41b617f923e29d54171b38d9171c8231eb1"
            },
            "downloads": -1,
            "filename": "naifu-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "26aed6a68df9fcfb7db5547c707666d1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 91415,
            "upload_time": "2024-02-17T15:51:42",
            "upload_time_iso_8601": "2024-02-17T15:51:42.772484Z",
            "url": "https://files.pythonhosted.org/packages/f1/d7/848386dc00def2745cd45295c33e1d55320394a448627dcbd656dea883a1/naifu-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69c0d598ff6ff7abde769e52863f4db48c05316b68dde57da59493dd690c6547",
                "md5": "92b4ad93577a8de00a65303334445d57",
                "sha256": "3240a31aa1aef44f7da48e9568316d21101c870eb0a8f0c4456c8b29e2f2cf2c"
            },
            "downloads": -1,
            "filename": "naifu-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "92b4ad93577a8de00a65303334445d57",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 74188,
            "upload_time": "2024-02-17T15:51:44",
            "upload_time_iso_8601": "2024-02-17T15:51:44.693161Z",
            "url": "https://files.pythonhosted.org/packages/69/c0/d598ff6ff7abde769e52863f4db48c05316b68dde57da59493dd690c6547/naifu-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-17 15:51:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mikubill",
    "github_project": "naifu-diffusion",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "naifu"
}
        
Elapsed time: 0.59796s