fix: add factor=28 to smart_resize in prepare_image for Qwen VL models

#2
by aug6th - opened
Files changed (1) hide show
  1. groundcua.py +4 -2
groundcua.py CHANGED
@@ -22,16 +22,18 @@ For each function call, return a json object with function name and arguments wi
22
  # Default generation parameters
23
  DEFAULT_TEMPERATURE = 0.0
24
  DEFAULT_MAX_NEW_TOKENS = 64
 
25
  MIN_PIXELS = 78_400
26
  MAX_PIXELS = 6_000_000
27
 
28
 
29
- def prepare_image(image, min_pixels=MIN_PIXELS, max_pixels=MAX_PIXELS):
30
  """
31
  Resize image using smart_resize for optimal model performance.
32
 
33
  Args:
34
  image: PIL Image object
 
35
  min_pixels: Minimum number of pixels (default: 78,400)
36
  max_pixels: Maximum number of pixels (default: 6,000,000)
37
 
@@ -42,7 +44,7 @@ def prepare_image(image, min_pixels=MIN_PIXELS, max_pixels=MAX_PIXELS):
42
 
43
  width, height = image.size
44
  resized_height, resized_width = smart_resize(
45
- height, width, min_pixels=min_pixels, max_pixels=max_pixels
46
  )
47
  resized_image = image.resize((resized_width, resized_height))
48
  return resized_image, (resized_width, resized_height)
 
22
  # Default generation parameters
23
  DEFAULT_TEMPERATURE = 0.0
24
  DEFAULT_MAX_NEW_TOKENS = 64
25
+ SMART_RESIZE_FACTOR = 28
26
  MIN_PIXELS = 78_400
27
  MAX_PIXELS = 6_000_000
28
 
29
 
30
+ def prepare_image(image, factor=SMART_RESIZE_FACTOR, min_pixels=MIN_PIXELS, max_pixels=MAX_PIXELS):
31
  """
32
  Resize image using smart_resize for optimal model performance.
33
 
34
  Args:
35
  image: PIL Image object
36
+ factor: Resize factor for smart_resize (default: 28)
37
  min_pixels: Minimum number of pixels (default: 78,400)
38
  max_pixels: Maximum number of pixels (default: 6,000,000)
39
 
 
44
 
45
  width, height = image.size
46
  resized_height, resized_width = smart_resize(
47
+ height, width, factor=factor, min_pixels=min_pixels, max_pixels=max_pixels
48
  )
49
  resized_image = image.resize((resized_width, resized_height))
50
  return resized_image, (resized_width, resized_height)