Wuvin commited on
Commit
0f829db
1 Parent(s): 7ad05d0

avoid memory leak

Browse files
gradio_app/custom_models/mvimg_prediction.py CHANGED
@@ -15,7 +15,7 @@ checkpoint_path = "ckpt/img2mvimg/unet_state_dict.pth"
15
  trainer, pipeline = load_pipeline(training_config, checkpoint_path)
16
 
17
  def predict(img_list: List[Image.Image], guidance_scale=2., **kwargs):
18
- pipeline.enable_model_cpu_offload()
19
  if isinstance(img_list, Image.Image):
20
  img_list = [img_list]
21
  img_list = [rgba_to_rgb(i) if i.mode == 'RGBA' else i for i in img_list]
 
15
  trainer, pipeline = load_pipeline(training_config, checkpoint_path)
16
 
17
  def predict(img_list: List[Image.Image], guidance_scale=2., **kwargs):
18
+ pipeline = pipeline.to("cuda")
19
  if isinstance(img_list, Image.Image):
20
  img_list = [img_list]
21
  img_list = [rgba_to_rgb(i) if i.mode == 'RGBA' else i for i in img_list]
gradio_app/custom_models/normal_prediction.py CHANGED
@@ -10,7 +10,7 @@ checkpoint_path = "ckpt/image2normal/unet_state_dict.pth"
10
  trainer, pipeline = load_pipeline(training_config, checkpoint_path)
11
 
12
  def predict_normals(image: List[Image.Image], guidance_scale=2., do_rotate=True, num_inference_steps=30, **kwargs):
13
- pipeline.enable_model_cpu_offload()
14
 
15
  img_list = image if isinstance(image, list) else [image]
16
  img_list = [rgba_to_rgb(i) if i.mode == 'RGBA' else i for i in img_list]
 
10
  trainer, pipeline = load_pipeline(training_config, checkpoint_path)
11
 
12
  def predict_normals(image: List[Image.Image], guidance_scale=2., do_rotate=True, num_inference_steps=30, **kwargs):
13
+ pipeline = pipeline.to("cuda")
14
 
15
  img_list = image if isinstance(image, list) else [image]
16
  img_list = [rgba_to_rgb(i) if i.mode == 'RGBA' else i for i in img_list]