1lint commited on
Commit
f94c315
1 Parent(s): 2414bfd

add readme, requirements files. add inpaint radio

Browse files
Files changed (3) hide show
  1. README.MD +10 -0
  2. app.py +13 -7
  3. requirements.txt +5 -0
README.MD ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # **Stable Diffusion Pipeline Web UI**
2
+
3
+ Stable Diffusion WebUI with first class support for HuggingFace Diffusers Pipelines and Diffusion Schedulers, made in the style of Automatic1111's WebUI and Evel_Space.
4
+
5
+ Supports Huggingface `Text-to-Image`, `Image to Image`, and `Inpainting` pipelines, with fast switching between pipeline modes by reusing loaded model weights already in memory.
6
+
7
+ Install requirements with `pip install -r requirements.txt`
8
+
9
+ Run with `python app.py`
10
+
app.py CHANGED
@@ -5,7 +5,7 @@ from inpaint_pipeline import SDInpaintPipeline as StableDiffusionInpaintPipeline
5
  from diffusers import (
6
  StableDiffusionPipeline,
7
  StableDiffusionImg2ImgPipeline,
8
- StableDiffusionInpaintPipelineLegacy # uncomment this line to use original inpaint pipeline
9
  )
10
 
11
  import diffusers.schedulers
@@ -34,12 +34,12 @@ scheduler_names = list(scheduler_dict.keys())
34
  default_scheduler = scheduler_names[3] # expected to be DPM Multistep
35
 
36
  model_ids = [
37
- "andite/anything-v4.0",
38
- "hakurei/waifu-diffusion",
39
- "prompthero/openjourney-v2",
40
- "runwayml/stable-diffusion-v1-5",
41
- "johnslegers/epic-diffusion",
42
- "stabilityai/stable-diffusion-2-1",
43
  ]
44
 
45
  loaded_model_id = ""
@@ -102,6 +102,7 @@ def generate(
102
  strength=0.5,
103
  inpaint_image=None,
104
  inpaint_strength=0.5,
 
105
  neg_prompt="",
106
  pipe_class=StableDiffusionPipeline,
107
  pipe_kwargs="{}",
@@ -161,6 +162,7 @@ def generate(
161
  init_image = inpaint_image["image"].resize((width, height))
162
  mask = inpaint_image["mask"].resize((width, height))
163
 
 
164
  result = pipe(
165
  prompt,
166
  negative_prompt=neg_prompt,
@@ -169,6 +171,7 @@ def generate(
169
  mask_image=mask,
170
  num_inference_steps=int(steps),
171
  strength=inpaint_strength,
 
172
  guidance_scale=guidance,
173
  generator=generator,
174
  )
@@ -254,6 +257,8 @@ with gr.Blocks(css="style.css") as demo:
254
  step=0.02,
255
  value=0.8,
256
  )
 
 
257
 
258
  with gr.Row():
259
  batch_size = gr.Slider(
@@ -315,6 +320,7 @@ with gr.Blocks(css="style.css") as demo:
315
  strength,
316
  inpaint_image,
317
  inpaint_strength,
 
318
  neg_prompt,
319
  pipe_state,
320
  pipe_kwargs,
 
5
  from diffusers import (
6
  StableDiffusionPipeline,
7
  StableDiffusionImg2ImgPipeline,
8
+ #StableDiffusionInpaintPipelineLegacy # uncomment this line to use original inpaint pipeline
9
  )
10
 
11
  import diffusers.schedulers
 
34
  default_scheduler = scheduler_names[3] # expected to be DPM Multistep
35
 
36
  model_ids = [
37
+ "andite/anything-v4.0",
38
+ "hakurei/waifu-diffusion",
39
+ "prompthero/openjourney-v2",
40
+ "runwayml/stable-diffusion-v1-5",
41
+ "johnslegers/epic-diffusion",
42
+ "stabilityai/stable-diffusion-2-1",
43
  ]
44
 
45
  loaded_model_id = ""
 
102
  strength=0.5,
103
  inpaint_image=None,
104
  inpaint_strength=0.5,
105
+ inpaint_radio='',
106
  neg_prompt="",
107
  pipe_class=StableDiffusionPipeline,
108
  pipe_kwargs="{}",
 
162
  init_image = inpaint_image["image"].resize((width, height))
163
  mask = inpaint_image["mask"].resize((width, height))
164
 
165
+
166
  result = pipe(
167
  prompt,
168
  negative_prompt=neg_prompt,
 
171
  mask_image=mask,
172
  num_inference_steps=int(steps),
173
  strength=inpaint_strength,
174
+ preserve_unmasked_image=(inpaint_radio == inpaint_options[0]),
175
  guidance_scale=guidance,
176
  generator=generator,
177
  )
 
257
  step=0.02,
258
  value=0.8,
259
  )
260
+ inpaint_options = ["preserve non-masked portions of image", "output entire inpainted image"]
261
+ inpaint_radio = gr.Radio(inpaint_options, value=inpaint_options[0], show_label=False, interactive=True)
262
 
263
  with gr.Row():
264
  batch_size = gr.Slider(
 
320
  strength,
321
  inpaint_image,
322
  inpaint_strength,
323
+ inpaint_radio,
324
  neg_prompt,
325
  pipe_state,
326
  pipe_kwargs,
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ diffusers==0.11.1
2
+ gradio==3.16.2
3
+ numpy==1.24.1
4
+ Pillow==9.4.0
5
+ torch==1.12.1+cu113