Code Monkey home page Code Monkey logo

sd-latent-upscaler's Introduction

SD-Latent-Upscaler

Upscaling stable diffusion latents using a small neural network.

Very similar to my latent interposer, this small model can be used to upscale latents in a way that doesn't ruin the image. I mostly explain some of the issues with upscaling latents in this issue. Think of this as an ESRGAN for latents, except severely undertrained.

Currently, SDXL has some minimal hue shift issues. Because of course it does.

Installation

ComfyUI

To install it, simply clone this repo to your custom_nodes folder using the following command: git clone https://github.com/city96/SD-Latent-Upscaler custom_nodes/SD-Latent-Upscaler.

Alternatively, you can download the comfy_latent_upscaler.py file to your ComfyUI/custom_nodes folder as well. You may need to install hfhub using the command pip install huggingface-hub inside your venv.

If you need the model weights for something else, they are hosted on HF under the same Apache2 license as the rest of the repo.

Auto1111

Currently not supported but it should be possible to use it at the hires-fix part.

Local models

The node pulls the required files from huggingface hub by default. You can create a models folder and place the modules there if you have a flaky connection or prefer to use it completely offline, it will load them locally instead. The path should be: ComfyUI/custom_nodes/SD-Latent-Upscaler/models

Alternatively, just clone the entire HF repo to it: git clone https://huggingface.co/city96/SD-Latent-Upscaler custom_nodes/SD-Latent-Upscaler/models

Usage/principle

Usage is fairly simple. You use it anywhere where you would upscale a latent. If you need a higher scale factor (e.g. x4), simply chain two of the upscalers.

LATENT_UPSCALER_ANI

LATENT_UPSCALER_V2

As part of a workflow - notice how the second stage works despite the low denoise of 0.2. The image remains relatively unchanged.

LATENT_UPSCALER_WF

Training

Upscaler v2.0

I decided to do some more research and change the network architecture alltogether. This one is just a bunch of Conv2d layers with an Upsample at the beginning, similar to before except I reduced the kernel size/padding and instead added more layers.

Trained for 1M iterations on DIV2K + Flickr2K. I changed to AdamW + L1 loss (from SGD and MSE loss) and added a OneCycleLR scheduler.

loss

Upscaler v1.0

This version was still relatively undertrained. Mostly a proof-of-concept.

Trained for 1M iterations on DIV2K + Flickr2K.

Loss graphs for v1.0 models

(Left is training loss, right is validation loss.)

loss

sd-latent-upscaler's People

Contributors

city96 avatar yoinked-h avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sd-latent-upscaler's Issues

upscaled latents look very wrong

I'm sure I'm doing something wrong. I'm trying to integrate the latent upscaler into imaginairy but the latents look like this after upscaling. I'm using latent-upscaler-v2.1_SDxl-x2.0.safetensors. Input latent is [1, 4, 128, 128]

Any ideas how I messed this up?

028936_1_ddim50_PS7 5_a_flower_ latent-upscaled
original image:
028936_1_ddim50_PS7 5_a_flower_ generated

Regarding the artifacts at the VAE level

Not sure what your training process is however were you training with the actual 1.0 vae?

or did you use the 0.9 vae? - it's known that an "invisible" (quite visible) watermark is baked into the 1.0 vae. (this is in your relation to the artifacts found with the SDXL VAE)

Loading issues

It shows successful loading in the console, but no related plugin node is found when using it in the browser interface.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.