• Stars
    star
    433
  • Rank 100,464 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 1 year ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

ControlNet-XS

These are ControlNet-XS weights trained on stabilityai/stable-diffusion-xl-base-1.0 and stabilityai/stable-diffusion-2-1 on edge and depthmap conditioning respectively. You can find more details and further visual examples on the project page ControlNet-XS.

The codebase

The code is based on on the StableDiffusion frameworks. To use the ControlNet-XS, you need to access the weights for the StableDiffusion version that you want to control separately. We provide the weights with both depth and edge control for StableDiffusion2.1 and StableDiffusion-XL at Huggingface

After obtaining the weights, you need the complete the config files with the paths to the checkpoints of the StableDiffusion base and ControlNet-XS.

1. Setting up the virtualenv

This is assuming you have navigated to the ControlNet-XS root after cloning it.

PyTorch 1.13

# install required packages from pypi
python3 -m venv .pt13
source .pt13/bin/activate
pip3 install -r requirements/pt13.txt

PyTorch 2.0

# install required packages from pypi
python3 -m venv .pt2
source .pt2/bin/activate
pip3 install -r requirements/pt2.txt

3. Install sgm

pip3 install .

Usage

Example for StableDiffusion-XL with Canny Edges

import scripts.control_utils as cu
import torch
from PIL import Image

path_to_config = 'ControlNet-XS-main/configs/inference/sdxl/sdxl_encD_canny_48m.yaml'
model = cu.create_model(path_to_config).to('cuda')

image_path = 'PATH/TO/IMAGES/Shoe.png'

canny_high_th = 250
canny_low_th = 100
size = 768
num_samples=2

image = cu.get_image(image_path, size=size)
edges = cu.get_canny_edges(image, low_th=canny_low_th, high_th=canny_high_th)

samples, controls = cu.get_sdxl_sample(
    guidance=edges,
    ddim_steps=10,
    num_samples=num_samples,
    model=model,
    shape=[4, size // 8, size // 8],
    control_scale=0.95,
    prompt='cinematic, shoe in the streets, made from meat, photorealistic shoe, highly detailed',
    n_prompt='lowres, bad anatomy, worst quality, low quality',
)


Image.fromarray(cu.create_image_grid(samples)).save('SDXL_MyShoe.png')

images_1)

Example for StableDiffuion2.1 with depth maps

import scripts.control_utils as cu
import torch
from PIL import Image

path_to_config = 'PATH/TO/CONFIG/sd21_encD_depth_14m.yaml'
model = cu.create_model(path_to_config).to('cuda')

size = 768
image_path = 'PATH/TO/IMAGES/Shoe.png'


image = cu.get_image(image_path, size=size)
depth = cu.get_midas_depth(image, max_resolution=size)
num_samples = 2

samples, controls = cu.get_sd_sample(
    guidance=depth,
    ddim_steps=10,
    num_samples=num_samples,
    model=model,
    shape=[4, size // 8, size // 8],
    control_scale=0.95,
    prompt='cinematic, advertising shot, shoe in a city street, photorealistic shoe, colourful, highly detailed',
    n_prompt='low quality, bad quality, sketches'
)


Image.fromarray(cu.create_image_grid(samples)).save('SD_MyShoe.png')

images_2)

More Repositories

1

FrEIA

Framework for Easily Invertible Architectures
Python
761
star
2

ngransac

Neural-Guided RANSAC for Estimating Epipolar Geometry from Sparse Correspondences
Python
305
star
3

LessMore

Learning Less is More - 6D Camera Localization via 3D Surface Regression
C++
258
star
4

dsacstar

DSAC* for Visual Camera Re-Localization (RGB or RGB-D)
C++
243
star
5

DSACLine

Differentiable RANSAC: Learning Robust Line Fitting
Python
218
star
6

conditional_INNs

Code for the paper "Guided Image Generation with Conditional Invertible Neural Networks" (2019)
Python
93
star
7

analyzing_inverse_problems

Code for the paper "Analyzing inverse problems with invertible neural networks." (2018)
Jupyter Notebook
82
star
8

esac

ESAC - Expert Sample Consensus Applied To Camera Re-Localization
C++
68
star
9

ngdsac_camreloc

Neural-Guided, Differentiable RANSAC for Camera Re-Localization (NG-DSAC++)
C++
48
star
10

IB-INN

Code for the paper "Training Normalizing Flows with the Information Bottleneck for Competitive Generative Classification" (2020)
Python
42
star
11

FFF

Free-form flows are a generative model training a pair of neural networks via maximum likelihood
Jupyter Notebook
34
star
12

ngdsac_horizon

Neural-Guided, Differentiable RANSAC for Horizon Line Estimation
Python
33
star
13

GIN

Code for the paper "Disentanglement by Nonlinear ICA with General Incompressible-flow Networks (GIN)" (2020)
Python
31
star
14

HINT

Code for the research paper "HINT: Hierarchical Invertible Neural Transport for Density Estimation and Bayesian Inference".
Python
19
star
15

trustworthy_GCs

Materials for the paper https://arxiv.org/pdf/2007.15036.pdf
14
star
16

3dcv-students

Exercises for the lecture "Computer Vision: 3D Reconstruction"
Jupyter Notebook
12
star
17

inn_toy_data

Code for artificial toy data sets used to evaluate (conditional) invertible neural networks and related methods
Python
11
star
18

Coupling-Universality

Jupyter Notebook
10
star
19

ML-Tutorial

Introduction to Machine Learning using scikit-learn and PyTorch
Jupyter Notebook
8
star
20

gmbench

Code for โ€œA Comparative Study of Graph Matching Algorithms in Computer Visonโ€ (ECCV 2022)
HTML
8
star
21

MLAE

Maximum Likelihood Training of Autoencoders
Jupyter Notebook
8
star
22

libct

A fast approximate primal-dual solver for tracking-by-assignment cell-tracking problems
C++
5
star
23

libmpopt

Library for Message Passing Optimization Techniques
C++
4
star
24

combilp

Exact MAP-Inference by Confining Combinatorial Search with LP Relaxation
Python
4
star
25

Gaussianization-Bound

Code to paper "On the Convergence Rate of Gaussianization with Random Rotations"
Python
3
star