• Stars
    star
    3,802
  • Rank 11,577 (Top 0.3 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 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

Outpainting with Stable Diffusion on an infinite canvas

stablediffusion-infinity

Outpainting with Stable Diffusion on an infinite canvas.

Open In Colab Hugging Face Spaces Setup Locally

outpaint

Girl.with.a.Pearl.Earring.mp4

Status

Powered by Stable Diffusion inpainting model, this project now works well. However, the quality of results is still not guaranteed. You may need to do prompt engineering, change the size of the selection, reduce the size of the outpainting region 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.

Update: the project add photometric correction to suppress seams, to use this feature, you need to install fpie: pip install fpie (Linux/MacOS only)

Docs

Get Started

FAQs

  • The result is a black square:
    • False positive rate of safety checker is relatively high, you may disable the safety_checker
    • Some GPUs might not work with fp16: python app.py --fp32 --lowvram
  • What is the init_mode
    • init_mode indicates how to fill the empty/masked region, usually patch_match is better than others
  • Why not use postMessage for iframe interaction
    • The iframe and the gradio are in the same origin. For postMessage version, check out gradio-space version

Known issues

  • The canvas is implemented with NumPy + PyScript (the project was originally implemented with ipycanvas inside a jupyter notebook), which is relatively inefficient compared with pure frontend solutions.
  • By design, the canvas is infinite. However, the canvas size is finite in practice. Your RAM and browser limit the canvas size. The canvas might crash or behave strangely when zoomed out by a certain scale.
  • The canvas requires internet: You can deploy and serve PyScript, Pyodide, and other JS/CSS assets with a local HTTP server and modify index.html accordingly.
  • Photometric correction might not work (taichi does not support the multithreading environment). A dirty hack (quite unreliable) is implemented to move related computation inside a subprocess.
  • Stable Diffusion inpainting model is much slower when selection size is larger than 512x512

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.

The submodule glid_3_xl_stable is based on https://github.com/Jack000/glid-3-xl-stable

The submodule PyPatchMatch is based on https://github.com/vacancy/PyPatchMatch

The code of postprocess.py and process.py is modified based on https://github.com/Trinkle23897/Fast-Poisson-Image-Editing

The code of convert_checkpoint.py is modified based on https://github.com/huggingface/diffusers/blob/main/scripts/convert_original_stable_diffusion_to_diffusers.py

The submodule sd_grpcserver and handleImageAdjustment() in utils.py are based on https://github.com/hafriedlander/stable-diffusion-grpcserver and https://github.com/parlance-zz/g-diffuser-bot

w2ui.min.js and w2ui.min.css is from https://github.com/vitmalina/w2ui. fabric.min.js is a custom build of https://github.com/fabricjs/fabric.js

interrogate.py is based on https://github.com/pharmapsychotic/clip-interrogator v1, the submodule blip_model is based on https://github.com/salesforce/BLIP

More Repositories

1

ocaml-manual-cn

OCaml ζ–‡ζ‘£δΈ­ζ–‡η‰ˆ
TeX
28
star
2

Image-Registration

An FFT-Based Technique for Translation, Rotation, and Scale-Invariant Image Registration
MATLAB
20
star
3

rockstar-ml

Rockstar interpreter in OCaml
OCaml
13
star
4

PAT-Basic-Level

"AC" Solutions for Zhejiang University Porgramming Ability Test Basic Level Practise with C
C
9
star
5

leetcode-py

Leetcode solutions in Python (1600/2600)
Python
6
star
6

Vector-Filed-Visualization-in-Waveguide-and-Resonator

基于 MATLAB ηš„ζ³’ε―Όγ€θ°ζŒ―ε™¨η‰Ήζ€§ηš„δΈ‰η»΄ε―θ§†εŒ–ζΌ”η€Ί
MATLAB
6
star
7

awesome-NeRFs

A list of Neural Radiance Field (NeRF) related papers
4
star
8

Sokoban-FPGA

Sokoban and minesweeper implemented in FPGA
Verilog
3
star
9

Sokoban-FPGA-core

game controller for Sokoban game implemented in FPGA with cocotb testbench
Verilog
3
star
10

rEFInd-ZJU

A rEFInd theme for the students of Zhejiang University.
3
star
11

cubic-stylization-py

Implementation of Cubic Stylization in Python
Python
2
star
12

simple-library-management-system

Course Project for Database System Concepts
JavaScript
2
star
13

simple-http-server

simple http server in C
C
2
star
14

pytorch-pitfalls

1
star
15

carry-select-adder

pipeline adder 32bit
Verilog
1
star
16

iot-smart

Single-page application for Modern Mobile Communication Application System Experiment in Zhejiang University
JavaScript
1
star
17

misc-toys

Python
1
star
18

how-does-debugger-work

How Does Debugger Work - A glance on ptrace - My presentation for OS Concept Course
C
1
star
19

regex-py

a simple regex module implemented in python
Python
1
star
20

OceanSim

Part of my bachelor thesis, rewrote for this repo
1
star
21

MipsPipelineCPU

32 bits pipeline mips cpu
Verilog
1
star
22

Minecraft-OpenGL

CG final project due 2017.01.10
C++
1
star
23

lab16-stop-watch

Verilog
1
star
24

PAT-Advanced-Level

Zhejiang University Porgramming Ability Test Advanced Level Practise
C
1
star
25

99-OCaml-Problems

OCaml
1
star