cocktailpeanut commited on
Commit
7ca6fbe
·
1 Parent(s): 86580f0
Files changed (1) hide show
  1. app.py +29 -26
app.py CHANGED
@@ -17,41 +17,44 @@ DEVICE = devicetorch.get(torch)
17
  def init():
18
  global pipe
19
 
20
- config_file = hf_hub_download(
21
- "xinsir/controlnet-union-sdxl-1.0",
22
- filename="config_promax.json",
23
- )
24
 
25
- config = ControlNetModel_Union.load_config(config_file)
26
- controlnet_model = ControlNetModel_Union.from_config(config)
27
- model_file = hf_hub_download(
28
- "xinsir/controlnet-union-sdxl-1.0",
29
- filename="diffusion_pytorch_model_promax.safetensors",
30
- )
31
- state_dict = load_state_dict(model_file)
32
- model, _, _, _, _ = ControlNetModel_Union._load_pretrained_model(
33
- controlnet_model, state_dict, model_file, "xinsir/controlnet-union-sdxl-1.0"
34
- )
35
- model.to(device=DEVICE, dtype=torch.float16)
 
 
 
 
 
36
 
37
- vae = AutoencoderKL.from_pretrained(
38
- "madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
39
- ).to(DEVICE)
40
 
41
- pipe = StableDiffusionXLFillPipeline.from_pretrained(
42
- "SG161222/RealVisXL_V5.0_Lightning",
43
- torch_dtype=torch.float16,
44
- vae=vae,
45
- controlnet=model,
46
- variant="fp16",
47
- ).to(DEVICE)
48
 
49
- pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
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