nroggendorff commited on
Commit
f152a6a
·
verified ·
1 Parent(s): 4457a67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -13
app.py CHANGED
@@ -67,19 +67,24 @@ def generate(prompt, negative_prompt, guidance, strength, seed, width, height):
67
 
68
  generator = torch.Generator(device="cuda").manual_seed(seed)
69
 
70
- result = pipe(
71
- prompt=prompt,
72
- negative_prompt=negative_prompt,
73
- width=width,
74
- height=height,
75
- num_inference_steps=NUM_INFERENCE_STEPS,
76
- guidance_scale=guidance,
77
- generator=generator,
78
- callback_on_step_end=callback,
79
- callback_on_step_end_tensor_inputs=["latents"],
80
- )
81
-
82
- return result.images[0]
 
 
 
 
 
83
 
84
 
85
  with gr.Blocks() as interface:
 
67
 
68
  generator = torch.Generator(device="cuda").manual_seed(seed)
69
 
70
+ try:
71
+ result = pipe(
72
+ prompt=prompt,
73
+ negative_prompt=negative_prompt,
74
+ width=width,
75
+ height=height,
76
+ num_inference_steps=NUM_INFERENCE_STEPS,
77
+ guidance_scale=guidance,
78
+ generator=generator,
79
+ callback_on_step_end=callback,
80
+ callback_on_step_end_tensor_inputs=["latents"],
81
+ )
82
+ image = result.images[0]
83
+ del result
84
+ return image
85
+ finally:
86
+ pipe.disable_lora()
87
+ torch.cuda.empty_cache()
88
 
89
 
90
  with gr.Blocks() as interface: