Giter Site home page Giter Site logo

dudrill / stablediffusion-infinity Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lkwq007/stablediffusion-infinity

0.0 0.0 0.0 16.58 MB

Outpainting with Stable Diffusion on an infinite canvas

License: Apache License 2.0

Shell 1.87% JavaScript 6.27% Python 75.51% HTML 11.61% Jupyter Notebook 3.96% Dockerfile 0.78%

stablediffusion-infinity's Introduction

stablediffusion-infinity

Outpainting with Stable Diffusion on an infinite canvas.

Open In Colab

Start with init_image (updated demo in Gradio):

Girl.with.a.Pearl.Earring.mp4

Start with text2img (ipycanvas version):

demo.mp4

The web app might work on Windows (see this issue lkwq007#12 for more information) and Apple Silicon devices (untested, check guide here: https://huggingface.co/docs/diffusers/optimization/mps).

Status

This project mainly works as a proof of concept. In that case, the UI design is relatively weak, and the quality of results is not guaranteed. You may need to do prompt engineering or change the size of the selection box to get better outpainting results.

The project now becomes a web app based on PyScript and Gradio. For Jupyter Notebook version, please check out the ipycanvas branch.

Pull requests are welcome for better UI control, ideas to achieve better results, or any other improvements.

Setup environment

setup with environment.yml

git clone --recurse-submodules https://github.com/lkwq007/stablediffusion-infinity
cd stablediffusion-infinity
conda env create -f environment.yml

if the environment.yml doesn't work for you, you may install dependencies manually:

conda create -n sd-inf python=3.10
conda activate sd-inf
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
conda install scipy scikit-image
conda install -c conda-forge diffusers transformers ftfy
pip install opencv-python
pip install gradio==3.4

For windows, you may need to replace pip install opencv-python with conda install -c conda-forge opencv

CPP library (optional)

Note that opencv library (e.g. libopencv-dev/opencv-devel, the package name may differ on different distributions) is required for PyPatchMatch. You may need to install opencv by yourself. If no opencv installed, the patch_match option (usually better quality) won't work.

How-to

conda activate sd-inf
python app.py

Running with Docker

This should get you started without needing to manually install anything, except for having an environment with Docker installed and an Nvidia GPU. This has been tested on Docker Desktop on Windows 10 using the WSL2 backend.

First, update the .env file with your Huggingface token from https://huggingface.co/settings/tokens

Open your shell that has docker and run these commands

cd stablediffusion-infinity
docker-compose build
docker-compose up

Watch the log for the url to open in your browser. Choose the one that starts with http://127.0.0.1:8888/

FAQs

  • Troubleshooting on Windows:
  • False positive rate of safety checker is quite high:
  • What is the init_mode
    • init_mode indicates how to fill the empty/masked region, usually patch_match is better than others

Credit

The code of perlin2d.py is from https://stackoverflow.com/questions/42147776/producing-2d-perlin-noise-with-numpy/42154921#42154921 and is not included in the scope of LICENSE used in this repo.

stablediffusion-infinity's People

Contributors

lkwq007 avatar tpsjr7 avatar lebmd avatar

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.