Ashoka74 commited on
Commit
2a156bc
1 Parent(s): 0ec586b

Update app_merged.py

Browse files
Files changed (1) hide show
  1. app_merged.py +6 -4
app_merged.py CHANGED
@@ -616,7 +616,7 @@ def infer(
616
  ):
617
  #logging.info(f"Input image shape: {image.shape}, dtype: {image.dtype}")
618
 
619
- clear_memory()
620
 
621
  # Convert input to PIL if needed
622
  if isinstance(image, np.ndarray):
@@ -624,6 +624,8 @@ def infer(
624
  image = Image.fromarray(image, 'RGBA')
625
  else: # RGB
626
  image = Image.fromarray(image, 'RGB')
 
 
627
 
628
  #logging.info(f"Converted to PIL Image mode: {image.mode}")
629
 
@@ -1055,12 +1057,12 @@ def use_orientation(selected_image:gr.SelectData):
1055
  def process_image(input_image, input_text):
1056
  """Main processing function for the Gradio interface"""
1057
 
1058
-
1059
- clear_memory()
1060
-
1061
  if isinstance(input_image, Image.Image):
1062
  input_image = np.array(input_image)
1063
 
 
 
 
1064
  # Initialize configs
1065
  API_TOKEN = "9c8c865e10ec1821bea79d9fa9dc8720"
1066
  SAM2_CHECKPOINT = "./checkpoints/sam2_hiera_large.pt"
 
616
  ):
617
  #logging.info(f"Input image shape: {image.shape}, dtype: {image.dtype}")
618
 
619
+
620
 
621
  # Convert input to PIL if needed
622
  if isinstance(image, np.ndarray):
 
624
  image = Image.fromarray(image, 'RGBA')
625
  else: # RGB
626
  image = Image.fromarray(image, 'RGB')
627
+
628
+ clear_memory()
629
 
630
  #logging.info(f"Converted to PIL Image mode: {image.mode}")
631
 
 
1057
  def process_image(input_image, input_text):
1058
  """Main processing function for the Gradio interface"""
1059
 
 
 
 
1060
  if isinstance(input_image, Image.Image):
1061
  input_image = np.array(input_image)
1062
 
1063
+
1064
+ clear_memory()
1065
+
1066
  # Initialize configs
1067
  API_TOKEN = "9c8c865e10ec1821bea79d9fa9dc8720"
1068
  SAM2_CHECKPOINT = "./checkpoints/sam2_hiera_large.pt"