Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
import requests
|
| 4 |
import torch
|
| 5 |
from diffusers import StableDiffusionControlNetImg2ImgPipeline, ControlNetModel, DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler
|
|
|
|
| 6 |
from diffusers.models import AutoencoderKL
|
| 7 |
from PIL import Image
|
| 8 |
from RealESRGAN import RealESRGAN
|
|
@@ -117,6 +118,7 @@ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
| 117 |
controlnet = ControlNetModel.from_single_file(
|
| 118 |
"models/ControlNet/control_v11f1e_sd15_tile.pth", torch_dtype=torch.float16
|
| 119 |
)
|
|
|
|
| 120 |
|
| 121 |
# Load the Stable Diffusion pipeline with Juggernaut Reborn model
|
| 122 |
model_path = "models/models/Stable-diffusion/juggernaut_reborn.safetensors"
|
|
@@ -124,7 +126,8 @@ pipe = StableDiffusionControlNetImg2ImgPipeline.from_single_file(
|
|
| 124 |
model_path,
|
| 125 |
controlnet=controlnet,
|
| 126 |
torch_dtype=torch.float16,
|
| 127 |
-
use_safetensors=True
|
|
|
|
| 128 |
)
|
| 129 |
|
| 130 |
# Load and set VAE
|
|
@@ -134,7 +137,6 @@ vae = AutoencoderKL.from_single_file(
|
|
| 134 |
)
|
| 135 |
pipe.vae = vae
|
| 136 |
|
| 137 |
-
|
| 138 |
# Load embeddings and LoRA models
|
| 139 |
pipe.load_textual_inversion("models/embeddings/verybadimagenegative_v1.3.pt")
|
| 140 |
pipe.load_textual_inversion("models/embeddings/JuggernautNegative-neg.pt")
|
|
@@ -248,7 +250,6 @@ def process_image(input_image, prompt, negative_prompt, resolution=2048, num_inf
|
|
| 248 |
|
| 249 |
return result
|
| 250 |
|
| 251 |
-
|
| 252 |
# Simple options
|
| 253 |
simple_options = [
|
| 254 |
gr.Image(type="pil", label="Input Image"),
|
|
@@ -268,5 +269,4 @@ iface = gr.Interface(
|
|
| 268 |
description="Upload an image and adjust the settings to process it using Stable Diffusion."
|
| 269 |
)
|
| 270 |
|
| 271 |
-
|
| 272 |
iface.launch()
|
|
|
|
| 3 |
import requests
|
| 4 |
import torch
|
| 5 |
from diffusers import StableDiffusionControlNetImg2ImgPipeline, ControlNetModel, DDIMScheduler, DPMSolverMultistepScheduler, EulerAncestralDiscreteScheduler, EulerDiscreteScheduler
|
| 6 |
+
from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker
|
| 7 |
from diffusers.models import AutoencoderKL
|
| 8 |
from PIL import Image
|
| 9 |
from RealESRGAN import RealESRGAN
|
|
|
|
| 118 |
controlnet = ControlNetModel.from_single_file(
|
| 119 |
"models/ControlNet/control_v11f1e_sd15_tile.pth", torch_dtype=torch.float16
|
| 120 |
)
|
| 121 |
+
safety_checker = StableDiffusionSafetyChecker.from_pretrained("CompVis/stable-diffusion-safety-checker")
|
| 122 |
|
| 123 |
# Load the Stable Diffusion pipeline with Juggernaut Reborn model
|
| 124 |
model_path = "models/models/Stable-diffusion/juggernaut_reborn.safetensors"
|
|
|
|
| 126 |
model_path,
|
| 127 |
controlnet=controlnet,
|
| 128 |
torch_dtype=torch.float16,
|
| 129 |
+
use_safetensors=True,
|
| 130 |
+
safety_checker=safety_checker
|
| 131 |
)
|
| 132 |
|
| 133 |
# Load and set VAE
|
|
|
|
| 137 |
)
|
| 138 |
pipe.vae = vae
|
| 139 |
|
|
|
|
| 140 |
# Load embeddings and LoRA models
|
| 141 |
pipe.load_textual_inversion("models/embeddings/verybadimagenegative_v1.3.pt")
|
| 142 |
pipe.load_textual_inversion("models/embeddings/JuggernautNegative-neg.pt")
|
|
|
|
| 250 |
|
| 251 |
return result
|
| 252 |
|
|
|
|
| 253 |
# Simple options
|
| 254 |
simple_options = [
|
| 255 |
gr.Image(type="pil", label="Input Image"),
|
|
|
|
| 269 |
description="Upload an image and adjust the settings to process it using Stable Diffusion."
|
| 270 |
)
|
| 271 |
|
|
|
|
| 272 |
iface.launch()
|