Krebzonide commited on
Commit
bce71e8
·
1 Parent(s): 08c17b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -21
app.py CHANGED
@@ -17,15 +17,6 @@ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype
17
  # model_base, vae=vae, torch_dtype=torch.float16, variant="fp16", use_safetensors=True
18
  #)
19
 
20
- pipe = StableDiffusionXLPipeline.from_single_file(
21
- model_url,
22
- torch_dtype = torch.float16,
23
- variant = "fp16",
24
- vae = vae,
25
- use_safetensors = True,
26
- use_auth_token="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"
27
- )
28
- pipe.to("cuda")
29
 
30
  css = """
31
  .btn-green {
@@ -58,18 +49,14 @@ def set_base_model(base_model_id):
58
  del pipe
59
  torch.cuda.empty_cache()
60
  gc.collect()
61
- pipe = load_pipe(base_model_id)
62
- return pipe
63
-
64
- def load_pipe(base_model_id):
65
- model_id = CONTROLNET_MODEL_IDS[task_name]
66
- pipe = DiffusionPipeline.from_pretrained(
67
- base_model_id,
68
- safety_checker=None,
69
- require_safety_checker=False,
70
- torch_dtype=torch.float16)
71
- pipe.scheduler = UniPCMultistepScheduler.from_config(
72
- pipe.scheduler.config)
73
  pipe.to("cuda")
74
  return pipe
75
 
@@ -90,5 +77,6 @@ with gr.Blocks(css=css) as demo:
90
 
91
  submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
92
 
 
93
  demo.queue(1)
94
  demo.launch(debug=True)
 
17
  # model_base, vae=vae, torch_dtype=torch.float16, variant="fp16", use_safetensors=True
18
  #)
19
 
 
 
 
 
 
 
 
 
 
20
 
21
  css = """
22
  .btn-green {
 
49
  del pipe
50
  torch.cuda.empty_cache()
51
  gc.collect()
52
+ pipe = StableDiffusionXLPipeline.from_single_file(
53
+ model_url,
54
+ torch_dtype = torch.float16,
55
+ variant = "fp16",
56
+ vae = vae,
57
+ use_safetensors = True,
58
+ use_auth_token="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"
59
+ )
 
 
 
 
60
  pipe.to("cuda")
61
  return pipe
62
 
 
77
 
78
  submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
79
 
80
+ set_base_model(model_url)
81
  demo.queue(1)
82
  demo.launch(debug=True)