openfree commited on
Commit
79eda41
·
verified ·
1 Parent(s): 40f1a1c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -20,22 +20,25 @@ config_file = hf_hub_download(
20
  config = ControlNetModel_Union.load_config(config_file)
21
  controlnet_model = ControlNetModel_Union.from_config(config)
22
 
23
-
24
  # Load the state dictionary
25
  model_file = hf_hub_download(
26
  "xinsir/controlnet-union-sdxl-1.0",
27
  filename="diffusion_pytorch_model_promax.safetensors",
28
  )
29
- state_dict = load_state_dict(model_file) # Define state_dict
30
 
31
- # Then extract the keys from the state_dict
32
  loaded_keys = list(state_dict.keys())
33
 
34
- # Then call the method with the additional parameter
35
- model, _, _, _, _ = ControlNetModel_Union._load_pretrained_model(
36
  controlnet_model, state_dict, model_file, "xinsir/controlnet-union-sdxl-1.0", loaded_keys
37
  )
38
 
 
 
 
 
39
 
40
  vae = AutoencoderKL.from_pretrained(
41
  "madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
 
20
  config = ControlNetModel_Union.load_config(config_file)
21
  controlnet_model = ControlNetModel_Union.from_config(config)
22
 
 
23
  # Load the state dictionary
24
  model_file = hf_hub_download(
25
  "xinsir/controlnet-union-sdxl-1.0",
26
  filename="diffusion_pytorch_model_promax.safetensors",
27
  )
28
+ state_dict = load_state_dict(model_file)
29
 
30
+ # Extract the keys from the state_dict
31
  loaded_keys = list(state_dict.keys())
32
 
33
+ # Call the method and store all returns in a variable
34
+ result = ControlNetModel_Union._load_pretrained_model(
35
  controlnet_model, state_dict, model_file, "xinsir/controlnet-union-sdxl-1.0", loaded_keys
36
  )
37
 
38
+ # Use the first element from the result
39
+ model = result[0]
40
+ model = model.to(device="cuda", dtype=torch.float16)
41
+
42
 
43
  vae = AutoencoderKL.from_pretrained(
44
  "madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16