Spaces:
Runtime error
Runtime error
Commit
·
7ca6fbe
1
Parent(s):
86580f0
update
Browse files
app.py
CHANGED
@@ -17,41 +17,44 @@ DEVICE = devicetorch.get(torch)
|
|
17 |
def init():
|
18 |
global pipe
|
19 |
|
20 |
-
|
21 |
-
"xinsir/controlnet-union-sdxl-1.0",
|
22 |
-
filename="config_promax.json",
|
23 |
-
)
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
-
|
50 |
|
51 |
|
52 |
#@spaces.GPU(duration=16)
|
53 |
def fill_image(prompt, image, model_selection):
|
54 |
init()
|
|
|
55 |
source = image["background"]
|
56 |
mask = image["layers"][0]
|
57 |
|
|
|
17 |
def init():
|
18 |
global pipe
|
19 |
|
20 |
+
if pipe is None:
|
|
|
|
|
|
|
21 |
|
22 |
+
config_file = hf_hub_download(
|
23 |
+
"xinsir/controlnet-union-sdxl-1.0",
|
24 |
+
filename="config_promax.json",
|
25 |
+
)
|
26 |
+
|
27 |
+
config = ControlNetModel_Union.load_config(config_file)
|
28 |
+
controlnet_model = ControlNetModel_Union.from_config(config)
|
29 |
+
model_file = hf_hub_download(
|
30 |
+
"xinsir/controlnet-union-sdxl-1.0",
|
31 |
+
filename="diffusion_pytorch_model_promax.safetensors",
|
32 |
+
)
|
33 |
+
state_dict = load_state_dict(model_file)
|
34 |
+
model, _, _, _, _ = ControlNetModel_Union._load_pretrained_model(
|
35 |
+
controlnet_model, state_dict, model_file, "xinsir/controlnet-union-sdxl-1.0"
|
36 |
+
)
|
37 |
+
model.to(device=DEVICE, dtype=torch.float16)
|
38 |
|
39 |
+
vae = AutoencoderKL.from_pretrained(
|
40 |
+
"madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
|
41 |
+
).to(DEVICE)
|
42 |
|
43 |
+
pipe = StableDiffusionXLFillPipeline.from_pretrained(
|
44 |
+
"SG161222/RealVisXL_V5.0_Lightning",
|
45 |
+
torch_dtype=torch.float16,
|
46 |
+
vae=vae,
|
47 |
+
controlnet=model,
|
48 |
+
variant="fp16",
|
49 |
+
).to(DEVICE)
|
50 |
|
51 |
+
pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
|
52 |
|
53 |
|
54 |
#@spaces.GPU(duration=16)
|
55 |
def fill_image(prompt, image, model_selection):
|
56 |
init()
|
57 |
+
print(f"image {image}")
|
58 |
source = image["background"]
|
59 |
mask = image["layers"][0]
|
60 |
|