ciaochaos commited on
Commit
9ba02a8
1 Parent(s): 98a92b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
3
  from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
4
  import torch
5
  torch.backends.cuda.matmul.allow_tf32 = True
 
6
 
7
  controlnet = ControlNetModel.from_pretrained("ioclab/control_v1p_sd15_brightness", torch_dtype=torch.float16, use_safetensors=True)
8
 
@@ -29,8 +30,8 @@ def infer(
29
  seed=1234,
30
  ):
31
 
32
- conditioning_image = Image.fromarray(conditioning_image)
33
- conditioning_image = conditioning_image.convert('L')
34
 
35
  g_cpu = torch.Generator()
36
 
@@ -51,6 +52,9 @@ def infer(
51
  controlnet_conditioning_scale=1.0,
52
  ).images[0]
53
 
 
 
 
54
  return output_image
55
 
56
  with gr.Blocks() as demo:
 
3
  from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
4
  import torch
5
  torch.backends.cuda.matmul.allow_tf32 = True
6
+ import gc
7
 
8
  controlnet = ControlNetModel.from_pretrained("ioclab/control_v1p_sd15_brightness", torch_dtype=torch.float16, use_safetensors=True)
9
 
 
30
  seed=1234,
31
  ):
32
 
33
+ conditioning_image_raw = Image.fromarray(conditioning_image)
34
+ conditioning_image = conditioning_image_raw.convert('L')
35
 
36
  g_cpu = torch.Generator()
37
 
 
52
  controlnet_conditioning_scale=1.0,
53
  ).images[0]
54
 
55
+ del conditioning_image, conditioning_image_raw
56
+ gc.collect()
57
+
58
  return output_image
59
 
60
  with gr.Blocks() as demo: