masterofaudio2077 commited on
Commit
5e92a22
·
verified ·
1 Parent(s): 67061fd

Fix silently-skipped resize/normalize from None-valued processor kwargs

Browse files

Florence2Processor.__call__ forwards do_resize/do_normalize/image_mean/image_std/resample/do_convert_rgb to the image processor unconditionally, defaulting to None when the caller doesn't override them. This transformers version's image processor treats an explicit None as "disable this feature", not "use the configured default" -- confirmed by direct testing: calling the bare CLIPImageProcessor with do_resize=None produces unresized 512x512 output (matching the raw input image) instead of the configured 768x768, and with do_normalize=None the output stays in raw [0,1] instead of the normalized [-2.12, 2.64] range, with no error in either case.

Only forward kwargs the caller actually set, so the image processor's own configured defaults apply otherwise. Verified live: resize now produces the correct 768x768 output for a 512x512 input image.

Files changed (1) hide show
  1. processing_florence2.py +19 -7
processing_florence2.py CHANGED
@@ -251,17 +251,29 @@ class Florence2Processor(ProcessorMixin):
251
  elif isinstance(text, list) and _is_str_or_image(text[0]):
252
  pass
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  pixel_values = self.image_processor(
255
  images,
256
- do_resize=do_resize,
257
- do_normalize=do_normalize,
258
  return_tensors=return_tensors,
259
- image_mean=image_mean,
260
- image_std=image_std,
261
- input_data_format=input_data_format,
262
  data_format=data_format,
263
- resample=resample,
264
- do_convert_rgb=do_convert_rgb,
265
  )["pixel_values"]
266
 
267
  if max_length is not None:
 
251
  elif isinstance(text, list) and _is_str_or_image(text[0]):
252
  pass
253
 
254
+ # None-valued kwargs must not be forwarded: this image processor treats an
255
+ # explicit None as "disable this feature" rather than "use the configured
256
+ # default", so passing do_resize=None (the default here when the caller
257
+ # doesn't override it) silently skips resizing -- and do_normalize=None
258
+ # silently skips normalization, with no error either way.
259
+ image_processor_overrides = {
260
+ k: v
261
+ for k, v in {
262
+ "do_resize": do_resize,
263
+ "do_normalize": do_normalize,
264
+ "image_mean": image_mean,
265
+ "image_std": image_std,
266
+ "input_data_format": input_data_format,
267
+ "resample": resample,
268
+ "do_convert_rgb": do_convert_rgb,
269
+ }.items()
270
+ if v is not None
271
+ }
272
  pixel_values = self.image_processor(
273
  images,
 
 
274
  return_tensors=return_tensors,
 
 
 
275
  data_format=data_format,
276
+ **image_processor_overrides,
 
277
  )["pixel_values"]
278
 
279
  if max_length is not None: