Tony Lian commited on
Commit
0cbad80
1 Parent(s): 1aae4d6

Empty cache after each generation

Browse files
Files changed (1) hide show
  1. generation.py +6 -0
generation.py CHANGED
@@ -65,6 +65,9 @@ def generate_single_object_with_box_batch(prompts, bboxes, phrases, words, input
65
  return_box_vis=True, save_all_latents=True, batched_condition=True, scheduler_key=scheduler_key
66
  )
67
 
 
 
 
68
  single_object_images.append(single_object_images_batch)
69
  single_object_pil_images_box_ann.append(single_object_pil_images_box_ann_batch)
70
  latents_all.append(latents_all_batch)
@@ -81,6 +84,9 @@ def generate_single_object_with_box_batch(prompts, bboxes, phrases, words, input
81
 
82
  latents_all = latents_all.transpose(0,1)[:,:,None,...]
83
 
 
 
 
84
  return latents_all, mask_selected_tensor, single_object_pil_images_box_ann
85
 
86
  def get_masked_latents_all_list(so_prompt_phrase_word_box_list, input_latents_list, so_input_embeddings, verbose=False, **kwargs):
 
65
  return_box_vis=True, save_all_latents=True, batched_condition=True, scheduler_key=scheduler_key
66
  )
67
 
68
+ gc.collect()
69
+ torch.cuda.empty_cache()
70
+
71
  single_object_images.append(single_object_images_batch)
72
  single_object_pil_images_box_ann.append(single_object_pil_images_box_ann_batch)
73
  latents_all.append(latents_all_batch)
 
84
 
85
  latents_all = latents_all.transpose(0,1)[:,:,None,...]
86
 
87
+ gc.collect()
88
+ torch.cuda.empty_cache()
89
+
90
  return latents_all, mask_selected_tensor, single_object_pil_images_box_ann
91
 
92
  def get_masked_latents_all_list(so_prompt_phrase_word_box_list, input_latents_list, so_input_embeddings, verbose=False, **kwargs):