• Stars
    star
    1,573
  • Rank 29,762 (Top 0.6 %)
  • Language
    Python
  • License
    Other
  • Created about 2 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Stable Diffusion in TensorFlow / Keras

Stable Diffusion in TensorFlow / Keras

A Keras / Tensorflow implementation of Stable Diffusion.

The weights were ported from the original implementation.

Colab Notebooks

The easiest way to try it out is to use one of the Colab notebooks:

Installation

Install as a python package

Install using pip with the git repo:

pip install git+https://github.com/divamgupta/stable-diffusion-tensorflow

Installing using the repo

Download the repo, either by downloading the zip file or by cloning the repo with git:

git clone [email protected]:divamgupta/stable-diffusion-tensorflow.git

Using pip without a virtual environment

Install dependencies using the requirements.txt file or the requirements_m1.txt file,:

pip install -r requirements.txt

Using a virtual environment with virtualenv

  1. Create your virtual environment for python3:

    python3 -m venv venv
  2. Activate your virtualenv:

    source venv/bin/activate
  3. Install dependencies using the requirements.txt file or the requirements_m1.txt file,:

    pip install -r requirements.txt

Usage

Using the Python interface

If you installed the package, you can use it as follows:

from stable_diffusion_tf.stable_diffusion import StableDiffusion
from PIL import Image

generator = StableDiffusion(
    img_height=512,
    img_width=512,
    jit_compile=False,
)
img = generator.generate(
    "An astronaut riding a horse",
    num_steps=50,
    unconditional_guidance_scale=7.5,
    temperature=1,
    batch_size=1,
)

# for image to image :
img = generator.generate(
    "A Halloween bedroom",
    num_steps=50,
    unconditional_guidance_scale=7.5,
    temperature=1,
    batch_size=1,
    input_image="/path/to/img.png"
)


Image.fromarray(img[0]).save("output.png")

Using text2image.py from the git repo

Assuming you have installed the required packages, you can generate images from a text prompt using:

python text2image.py --prompt="An astronaut riding a horse"

The generated image will be named output.png on the root of the repo. If you want to use a different name, use the --output flag.

python text2image.py --prompt="An astronaut riding a horse" --output="my_image.png"

Check out the text2image.py file for more options, including image size, number of steps, etc.

Using img2img.py from the git repo

Assuming you have installed the required packages, you can modify images from a text prompt using:

python img2img.py --prompt="a high quality sketch of people standing with sun and grass , watercolor , pencil color" --input="img.jpeg"

The generated image will be named img2img-out.jpeg by default on the root of the repo. If you want to use a different name, use the --output flag.

Check out the img2img.py file for more options, including the number of steps.

Example outputs

The following outputs have been generated using this implementation:

  1. A epic and beautiful rococo werewolf drinking coffee, in a burning coffee shop. ultra-detailed. anime, pixiv, uhd 8k cryengine, octane render

a

  1. Spider-Gwen Gwen-Stacy Skyscraper Pink White Pink-White Spiderman Photo-realistic 4K

a

  1. A vision of paradise, Unreal Engine

a

Inpainting

a

Image2Image

  1. a high quality sketch of people standing with sun and grass , watercolor , pencil color

Screen Shot 2022-10-09 at 9 34 30 AM

Keras Stable Diffusion Video Generation

  1. A beautiful street view of prague, artstation concept art, extremely detailed oil painting, vivid colors
StableFun.4.mp4

References

  1. https://github.com/CompVis/stable-diffusion
  2. https://github.com/geohot/tinygrad/blob/master/examples/stable_diffusion.py

More Repositories

1

diffusionbee-stable-diffusion-ui

Diffusion Bee is the easiest way to run Stable Diffusion locally on your M1 Mac. Comes with a one-click installer. No dependencies or technical knowledge needed.
JavaScript
12,342
star
2

image-segmentation-keras

Implementation of Segnet, FCN, UNet , PSPNet and other models in Keras.
Python
2,892
star
3

obsidian-spreadsheets

CSS
128
star
4

ladder_network_keras

Semi-Supervised Learning with Ladder Networks in Keras. Get 98% test accuracy on MNIST with just 100 labeled examples !
Python
101
star
5

deep-clustering-kingdra

Official implementation of ICLR 2020 paper Unsupervised Clustering using Pseudo-semi-supervised Learning
Python
48
star
6

lstm-gender-predictor

Predict the gender of a name using LSTM
Python
41
star
7

attention-translation-keras

Attention based sequence to sequence neural machine translation model built in keras.
Python
30
star
8

sbevnet-stereo-layout-estimation

This repository contains the code for "SBEVNet: End-to-End Deep Stereo Layout Estimation" paper by Divam Gupta, Wei Pu, Trenton Tabor, Jeff Schneider
Python
23
star
9

mtl_girnet

Code and datasets for our AAAI'19 paper : GIRNet: Interleaved Multi-Task Recurrent State Sequence Models
Python
6
star
10

datasets

5
star
11

pytorch-propane

Pytorch Propane is a simplified wrapper to make training and evaluation of neural networks easy and scalable.
Python
5
star
12

mttdsc

Code for our PAKDD'19 paper "Multi-task Learning for Target-dependent Sentiment Classification"
Python
5
star
13

PliceFS

Minimal file system implemented in C++.
C++
2
star
14

cppshell

Minimal shell implemented in C++
C++
2
star
15

divamgupta.github.io

HTML
2
star