joanrodai commited on
Commit
4dce64a
·
verified ·
1 Parent(s): 81663e2

Update processing_starvector.py

Browse files
Files changed (1) hide show
  1. processing_starvector.py +10 -0
processing_starvector.py CHANGED
@@ -64,4 +64,14 @@ class SimpleStarVectorProcessor(ProcessorMixin):
64
  if text is not None:
65
  text_inputs = self.tokenizer(text, **kwargs)
66
  return BatchFeature(data={**text_inputs, **image_inputs})
 
 
 
 
 
 
 
 
 
 
67
  AutoProcessor.register(SimpleStarVectorProcessor, SimpleStarVectorProcessor)
 
64
  if text is not None:
65
  text_inputs = self.tokenizer(text, **kwargs)
66
  return BatchFeature(data={**text_inputs, **image_inputs})
67
+
68
+ def _pad_to_square(self, img):
69
+ # Calculate padding to make the image square
70
+ width, height = img.size
71
+ max_dim = max(width, height)
72
+ padding = [(max_dim - width) // 2, (max_dim - height) // 2]
73
+ padding += [max_dim - width - padding[0], max_dim - height - padding[1]]
74
+ return pad(img, padding, fill=255) # Assuming white padding
75
+
76
+
77
  AutoProcessor.register(SimpleStarVectorProcessor, SimpleStarVectorProcessor)