primerz commited on
Commit
ca59ddb
·
verified ·
1 Parent(s): 0d4d25b

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +3 -3
utils.py CHANGED
@@ -11,10 +11,10 @@ captioner_processor = None
11
  captioner_model = None
12
 
13
  def resize_image_to_1mp(image):
14
- """Resizes image to approx 1MP (e.g., 768x768) preserving aspect ratio."""
15
  image = image.convert("RGB")
16
  w, h = image.size
17
- target_pixels = 768 * 768
18
  aspect_ratio = w / h
19
 
20
  # Calculate new dimensions
@@ -26,7 +26,7 @@ def resize_image_to_1mp(image):
26
  new_h = (new_h // 64) * 64
27
 
28
  if new_w == 0 or new_h == 0:
29
- new_w, new_h = 768 * 768 # Fallback
30
 
31
  return image.resize((new_w, new_h), Image.LANCZOS)
32
 
 
11
  captioner_model = None
12
 
13
  def resize_image_to_1mp(image):
14
+ """Resizes image to approx 1MP (e.g., 1024x1024) preserving aspect ratio."""
15
  image = image.convert("RGB")
16
  w, h = image.size
17
+ target_pixels = 1024 * 1024
18
  aspect_ratio = w / h
19
 
20
  # Calculate new dimensions
 
26
  new_h = (new_h // 64) * 64
27
 
28
  if new_w == 0 or new_h == 0:
29
+ new_w, new_h = 1024, 1024 # Fallback
30
 
31
  return image.resize((new_w, new_h), Image.LANCZOS)
32