mart9992 commited on
Commit
593c01e
1 Parent(s): 0e959bc

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +13 -1
handler.py CHANGED
@@ -665,8 +665,20 @@ class EndpointHandler():
665
 
666
  with_big_tits = data.get("with_big_tits", False)
667
 
668
- nude_pils = get_nude(get_mask_function=just_fucking_get_sd_mask, cfg_scale=data.get("cfg_scale"), generate_max_size=data.get("generate_max_size"), original_max_size=data.get(
 
 
 
669
  "original_max_size"), original_pil=original_pil, positive_prompt=data.get("positive_prompt"), steps=data.get("steps"), with_small_tits=with_small_tits, with_big_tits=with_big_tits)
 
 
 
 
 
 
 
 
 
670
 
671
  filenames = []
672
 
 
665
 
666
  with_big_tits = data.get("with_big_tits", False)
667
 
668
+ nude_pils = []
669
+
670
+ try:
671
+ nude_pils = get_nude(get_mask_function=just_fucking_get_sd_mask, cfg_scale=data.get("cfg_scale"), generate_max_size=data.get("generate_max_size"), original_max_size=data.get(
672
  "original_max_size"), original_pil=original_pil, positive_prompt=data.get("positive_prompt"), steps=data.get("steps"), with_small_tits=with_small_tits, with_big_tits=with_big_tits)
673
+ except RuntimeError as e:
674
+ if 'out of memory' in str(e):
675
+ torch.cuda.empty_cache()
676
+ nude_pils = get_nude(get_mask_function=just_fucking_get_sd_mask, cfg_scale=data.get("cfg_scale"), generate_max_size=data.get("generate_max_size"), original_max_size=data.get(
677
+ "original_max_size"), original_pil=original_pil, positive_prompt=data.get("positive_prompt"), steps=data.get("steps"), with_small_tits=with_small_tits, with_big_tits=with_big_tits)
678
+ print("CUDA Out of Memory, clearing cache")
679
+ # Optionally, you can retry your operation here, or handle the exception further
680
+ else:
681
+ raise
682
 
683
  filenames = []
684