Krebzonide commited on
Commit
ca74145
·
1 Parent(s): 459e60d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -14
app.py CHANGED
@@ -48,19 +48,32 @@ def generate(prompt, neg_prompt, samp_steps, guide_scale, batch_size, seed, heig
48
  return [(img, f"Image {i+1}") for i, img in enumerate(images)]
49
 
50
  def set_base_model(base_model_id):
51
- del pipe
52
- torch.cuda.empty_cache()
53
- gc.collect()
54
- pipe = StableDiffusionXLPipeline.from_single_file(
55
- model_url,
56
- torch_dtype = torch.float16,
57
- variant = "fp16",
58
- vae = vae,
59
- use_safetensors = True,
60
- use_auth_token="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"
61
- )
62
- pipe.to("cuda")
63
- return pipe
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  with gr.Blocks(css=css) as demo:
66
  with gr.Column():
@@ -79,6 +92,6 @@ with gr.Blocks(css=css) as demo:
79
 
80
  submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
81
 
82
- set_base_model(model_url)
83
  demo.queue(1)
84
  demo.launch(debug=True)
 
48
  return [(img, f"Image {i+1}") for i, img in enumerate(images)]
49
 
50
  def set_base_model(base_model_id):
51
+ global pipe
52
+ del pipe
53
+ torch.cuda.empty_cache()
54
+ gc.collect()
55
+ pipe = StableDiffusionXLPipeline.from_single_file(
56
+ model_url,
57
+ torch_dtype = torch.float16,
58
+ variant = "fp16",
59
+ vae = vae,
60
+ use_safetensors = True,
61
+ use_auth_token="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"
62
+ )
63
+ #pipe = load_model(base_model_id)
64
+ pipe.to("cuda")
65
+ return pipe
66
+
67
+ def load_model(base_model_id):
68
+ pipe = StableDiffusionXLPipeline.from_single_file(
69
+ model_url,
70
+ torch_dtype = torch.float16,
71
+ variant = "fp16",
72
+ vae = vae,
73
+ use_safetensors = True,
74
+ use_auth_token="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"
75
+ )
76
+
77
 
78
  with gr.Blocks(css=css) as demo:
79
  with gr.Column():
 
92
 
93
  submit_btn.click(generate, [prompt, negative_prompt, samp_steps, guide_scale, batch_size, seed, height, width], [gallery], queue=True)
94
 
95
+ pipe = set_base_model(model_url)
96
  demo.queue(1)
97
  demo.launch(debug=True)