update processor
Browse files- processing_aria.py +6 -2
- vision_processor.py +25 -3
processing_aria.py
CHANGED
|
@@ -70,11 +70,12 @@ class AriaProcessor(ProcessorMixin):
|
|
| 70 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 71 |
tokenizer, trust_remote_code=True, use_fast=False
|
| 72 |
)
|
| 73 |
-
if self.tokenizer.pad_token is None:
|
| 74 |
-
self.tokenizer.pad_token = self.tokenizer.unk_token
|
| 75 |
else:
|
| 76 |
self.tokenizer = tokenizer
|
| 77 |
|
|
|
|
|
|
|
|
|
|
| 78 |
self.image_token = image_token
|
| 79 |
|
| 80 |
# Copied from transformers.models.llava_next.processing_llave_next.LlavaNextProcessor.__call__
|
|
@@ -227,9 +228,12 @@ class AriaProcessor(ProcessorMixin):
|
|
| 227 |
image_processor_path,
|
| 228 |
**cls._extract_kwargs(AriaVisionProcessor.from_pretrained, **kwargs),
|
| 229 |
)
|
|
|
|
|
|
|
| 230 |
try:
|
| 231 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 232 |
tokenizer_path,
|
|
|
|
| 233 |
**cls._extract_kwargs(AutoTokenizer.from_pretrained, **kwargs),
|
| 234 |
)
|
| 235 |
chat_template = tokenizer.chat_template
|
|
|
|
| 70 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 71 |
tokenizer, trust_remote_code=True, use_fast=False
|
| 72 |
)
|
|
|
|
|
|
|
| 73 |
else:
|
| 74 |
self.tokenizer = tokenizer
|
| 75 |
|
| 76 |
+
if self.tokenizer.pad_token is None:
|
| 77 |
+
self.tokenizer.pad_token = self.tokenizer.unk_token
|
| 78 |
+
|
| 79 |
self.image_token = image_token
|
| 80 |
|
| 81 |
# Copied from transformers.models.llava_next.processing_llave_next.LlavaNextProcessor.__call__
|
|
|
|
| 228 |
image_processor_path,
|
| 229 |
**cls._extract_kwargs(AriaVisionProcessor.from_pretrained, **kwargs),
|
| 230 |
)
|
| 231 |
+
if "use_fast" in kwargs:
|
| 232 |
+
kwargs.pop("use_fast")
|
| 233 |
try:
|
| 234 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 235 |
tokenizer_path,
|
| 236 |
+
use_fast=False,
|
| 237 |
**cls._extract_kwargs(AutoTokenizer.from_pretrained, **kwargs),
|
| 238 |
)
|
| 239 |
chat_template = tokenizer.chat_template
|
vision_processor.py
CHANGED
|
@@ -210,14 +210,25 @@ class AriaVisionProcessor(BaseImageProcessor):
|
|
| 210 |
return_tensors: Optional[Union[str, TensorType]] = "pt",
|
| 211 |
split_image: Optional[bool] = False,
|
| 212 |
split_ratio: Optional[List[List[int]]] = [
|
| 213 |
-
[1, 1],
|
| 214 |
[1, 2],
|
| 215 |
[1, 3],
|
| 216 |
[1, 4],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
[2, 2],
|
| 218 |
[2, 1],
|
| 219 |
[3, 1],
|
|
|
|
| 220 |
[4, 1],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
],
|
| 222 |
):
|
| 223 |
"""
|
|
@@ -279,14 +290,25 @@ class AriaVisionProcessor(BaseImageProcessor):
|
|
| 279 |
return_tensors: Optional[Union[str, TensorType]] = None,
|
| 280 |
split_image: Optional[bool] = False,
|
| 281 |
split_ratio: Optional[List[List[int]]] = [
|
| 282 |
-
[1, 1],
|
| 283 |
[1, 2],
|
| 284 |
[1, 3],
|
| 285 |
[1, 4],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
[2, 2],
|
| 287 |
[2, 1],
|
| 288 |
[3, 1],
|
|
|
|
| 289 |
[4, 1],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
],
|
| 291 |
):
|
| 292 |
return self.__call__(
|
|
@@ -296,4 +318,4 @@ class AriaVisionProcessor(BaseImageProcessor):
|
|
| 296 |
return_tensors=return_tensors,
|
| 297 |
split_image=split_image,
|
| 298 |
split_ratio=split_ratio,
|
| 299 |
-
)
|
|
|
|
| 210 |
return_tensors: Optional[Union[str, TensorType]] = "pt",
|
| 211 |
split_image: Optional[bool] = False,
|
| 212 |
split_ratio: Optional[List[List[int]]] = [
|
|
|
|
| 213 |
[1, 2],
|
| 214 |
[1, 3],
|
| 215 |
[1, 4],
|
| 216 |
+
[1, 5],
|
| 217 |
+
[1, 6],
|
| 218 |
+
[1, 7],
|
| 219 |
+
[1, 8],
|
| 220 |
+
[2, 4],
|
| 221 |
+
[2, 3],
|
| 222 |
[2, 2],
|
| 223 |
[2, 1],
|
| 224 |
[3, 1],
|
| 225 |
+
[3, 2],
|
| 226 |
[4, 1],
|
| 227 |
+
[4, 2],
|
| 228 |
+
[5, 1],
|
| 229 |
+
[6, 1],
|
| 230 |
+
[7, 1],
|
| 231 |
+
[8, 1],
|
| 232 |
],
|
| 233 |
):
|
| 234 |
"""
|
|
|
|
| 290 |
return_tensors: Optional[Union[str, TensorType]] = None,
|
| 291 |
split_image: Optional[bool] = False,
|
| 292 |
split_ratio: Optional[List[List[int]]] = [
|
|
|
|
| 293 |
[1, 2],
|
| 294 |
[1, 3],
|
| 295 |
[1, 4],
|
| 296 |
+
[1, 5],
|
| 297 |
+
[1, 6],
|
| 298 |
+
[1, 7],
|
| 299 |
+
[1, 8],
|
| 300 |
+
[2, 4],
|
| 301 |
+
[2, 3],
|
| 302 |
[2, 2],
|
| 303 |
[2, 1],
|
| 304 |
[3, 1],
|
| 305 |
+
[3, 2],
|
| 306 |
[4, 1],
|
| 307 |
+
[4, 2],
|
| 308 |
+
[5, 1],
|
| 309 |
+
[6, 1],
|
| 310 |
+
[7, 1],
|
| 311 |
+
[8, 1],
|
| 312 |
],
|
| 313 |
):
|
| 314 |
return self.__call__(
|
|
|
|
| 318 |
return_tensors=return_tensors,
|
| 319 |
split_image=split_image,
|
| 320 |
split_ratio=split_ratio,
|
| 321 |
+
)
|