Spaces:
Paused
Paused
Changed to DPMSolverMultistepScheduler
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ generator = torch.Generator(device).manual_seed(lastSeed)
|
|
20 |
modelNames = ["stabilityai/stable-diffusion-2-inpainting",
|
21 |
"runwayml/stable-diffusion-inpainting"]
|
22 |
modelIndex = 0
|
23 |
-
|
24 |
oldLatentWalk = None
|
25 |
activeLatents = None
|
26 |
|
@@ -38,16 +38,18 @@ def GenerateNewLatentsForInference():
|
|
38 |
|
39 |
def InitializeOutpainting():
|
40 |
print("Initializing Outpainting")
|
41 |
-
global
|
42 |
if deviceStr == "cuda":
|
43 |
-
|
44 |
torch_dtype=torch.float16)
|
45 |
#safety_checker=lambda images, **kwargs: (images, False))
|
46 |
-
|
47 |
-
|
48 |
else:
|
49 |
-
|
50 |
#safety_checker=lambda images, **kwargs: (images, False))
|
|
|
|
|
51 |
|
52 |
# Based on: https://discuss.pytorch.org/t/help-regarding-slerp-function-for-generative-model-sampling/32475/4
|
53 |
# Further optimized to trade a divide operation for a multiply
|
@@ -77,7 +79,7 @@ def Diffuse(latentWalk, staticLatents, generatorSeed, inputImage, mask, pauseInf
|
|
77 |
generator = torch.Generator(device).manual_seed(generatorSeed)
|
78 |
lastSeed = generatorSeed
|
79 |
|
80 |
-
newImage =
|
81 |
negative_prompt=negativePrompt,
|
82 |
image=inputImage,
|
83 |
mask_image=mask,
|
@@ -103,7 +105,7 @@ print("Initializing Gradio Interface")
|
|
103 |
|
104 |
defaultMask = Image.open("assets/masks/diamond.png")
|
105 |
numInfStepsDesc = "A higher value generally increases quality, but reduces the frames per second of the output stream."
|
106 |
-
staticLatentsDesc = "This setting increases the frame to frame determisn of the generation. If this is disabled, then the
|
107 |
generatorSeedDesc = "Identical seeds allow for persistent scene generation between runs, and changing the seed will take a static large walk across the latent space to better control and alter the generation of scene scene content especially when large abberations exist in the reconstruction."
|
108 |
promptDesc = "This text will condition the generation of the scene to help guide the content creation."
|
109 |
negPromptDesc = "This text will help deter the generation from converging towards reconstructing the elements described in the text."
|
|
|
20 |
modelNames = ["stabilityai/stable-diffusion-2-inpainting",
|
21 |
"runwayml/stable-diffusion-inpainting"]
|
22 |
modelIndex = 0
|
23 |
+
outpaintPipeline = None
|
24 |
oldLatentWalk = None
|
25 |
activeLatents = None
|
26 |
|
|
|
38 |
|
39 |
def InitializeOutpainting():
|
40 |
print("Initializing Outpainting")
|
41 |
+
global outpaintPipeline
|
42 |
if deviceStr == "cuda":
|
43 |
+
outpaintPipeline = StableDiffusionInpaintPipeline.from_pretrained(modelNames[modelIndex],
|
44 |
torch_dtype=torch.float16)
|
45 |
#safety_checker=lambda images, **kwargs: (images, False))
|
46 |
+
outpaintPipeline.to(device)
|
47 |
+
outpaintPipeline.enable_xformers_memory_efficient_attention()
|
48 |
else:
|
49 |
+
outpaintPipeline = StableDiffusionInpaintPipeline.from_pretrained(modelNames[modelIndex])
|
50 |
#safety_checker=lambda images, **kwargs: (images, False))
|
51 |
+
|
52 |
+
outpaintPipeline.scheduler = DPMSolverMultistepScheduler.from_config(outpaintPipeline.scheduler.config)
|
53 |
|
54 |
# Based on: https://discuss.pytorch.org/t/help-regarding-slerp-function-for-generative-model-sampling/32475/4
|
55 |
# Further optimized to trade a divide operation for a multiply
|
|
|
79 |
generator = torch.Generator(device).manual_seed(generatorSeed)
|
80 |
lastSeed = generatorSeed
|
81 |
|
82 |
+
newImage = outpaintPipeline(prompt=prompt,
|
83 |
negative_prompt=negativePrompt,
|
84 |
image=inputImage,
|
85 |
mask_image=mask,
|
|
|
105 |
|
106 |
defaultMask = Image.open("assets/masks/diamond.png")
|
107 |
numInfStepsDesc = "A higher value generally increases quality, but reduces the frames per second of the output stream."
|
108 |
+
staticLatentsDesc = "This setting increases the frame to frame determisn of the generation. If this is disabled, then the inference will take continuous large walks across the latent space between frames."
|
109 |
generatorSeedDesc = "Identical seeds allow for persistent scene generation between runs, and changing the seed will take a static large walk across the latent space to better control and alter the generation of scene scene content especially when large abberations exist in the reconstruction."
|
110 |
promptDesc = "This text will condition the generation of the scene to help guide the content creation."
|
111 |
negPromptDesc = "This text will help deter the generation from converging towards reconstructing the elements described in the text."
|