Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,16 +24,6 @@ import cv2
|
|
24 |
|
25 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
26 |
|
27 |
-
controlnet = ControlNetModel.from_pretrained(
|
28 |
-
"diffusers/controlnet-canny-sdxl-1.0",
|
29 |
-
torch_dtype=torch.float16
|
30 |
-
)
|
31 |
-
|
32 |
-
controlnet_lineart = ControlNetModel.from_pretrained(
|
33 |
-
"fffiloni/cn_malgras_test_11",
|
34 |
-
torch_dtype=torch.float16,
|
35 |
-
token=hf_token
|
36 |
-
)
|
37 |
|
38 |
def check_use_custom_or_no(value):
|
39 |
if value is True:
|
@@ -114,17 +104,6 @@ def resize_image(input_path, output_path, target_height):
|
|
114 |
|
115 |
@spaces.GPU
|
116 |
def infer(use_custom_model, model_name, weight_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed, progress=gr.Progress(track_tqdm=True)):
|
117 |
-
|
118 |
-
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
119 |
-
"stabilityai/stable-diffusion-xl-base-1.0",
|
120 |
-
controlnet=controlnet_lineart,
|
121 |
-
vae=vae,
|
122 |
-
torch_dtype=torch.float16,
|
123 |
-
variant="fp16",
|
124 |
-
use_safetensors=True
|
125 |
-
)
|
126 |
-
|
127 |
-
pipe.to(device)
|
128 |
|
129 |
prompt = prompt
|
130 |
negative_prompt = negative_prompt
|
@@ -149,12 +128,34 @@ def infer(use_custom_model, model_name, weight_name, custom_lora_weight, image_i
|
|
149 |
image = np.concatenate([image, image, image], axis=2)
|
150 |
image = Image.fromarray(image)
|
151 |
|
|
|
|
|
|
|
|
|
|
|
152 |
if preprocessor == "lineart":
|
153 |
image = Image.open(image_in)
|
154 |
image = image.convert("RGB")
|
155 |
image = np.array(image)
|
156 |
#image = 255 - image
|
157 |
image = Image.fromarray(image)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
if use_custom_model:
|
160 |
|
|
|
24 |
|
25 |
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def check_use_custom_or_no(value):
|
29 |
if value is True:
|
|
|
104 |
|
105 |
@spaces.GPU
|
106 |
def infer(use_custom_model, model_name, weight_name, custom_lora_weight, image_in, prompt, negative_prompt, preprocessor, controlnet_conditioning_scale, guidance_scale, inf_steps, seed, progress=gr.Progress(track_tqdm=True)):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
prompt = prompt
|
109 |
negative_prompt = negative_prompt
|
|
|
128 |
image = np.concatenate([image, image, image], axis=2)
|
129 |
image = Image.fromarray(image)
|
130 |
|
131 |
+
controlnet = ControlNetModel.from_pretrained(
|
132 |
+
"diffusers/controlnet-canny-sdxl-1.0",
|
133 |
+
torch_dtype=torch.float16
|
134 |
+
)
|
135 |
+
|
136 |
if preprocessor == "lineart":
|
137 |
image = Image.open(image_in)
|
138 |
image = image.convert("RGB")
|
139 |
image = np.array(image)
|
140 |
#image = 255 - image
|
141 |
image = Image.fromarray(image)
|
142 |
+
|
143 |
+
controlnet = ControlNetModel.from_pretrained(
|
144 |
+
"fffiloni/cn_malgras_test_11",
|
145 |
+
torch_dtype=torch.float16,
|
146 |
+
token=hf_token
|
147 |
+
)
|
148 |
+
|
149 |
+
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
150 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
151 |
+
controlnet=controlnet_lineart,
|
152 |
+
vae=vae,
|
153 |
+
torch_dtype=torch.float16,
|
154 |
+
variant="fp16",
|
155 |
+
use_safetensors=True
|
156 |
+
)
|
157 |
+
|
158 |
+
pipe.to(device)
|
159 |
|
160 |
if use_custom_model:
|
161 |
|