Lukas Pfahler commited on
Commit
42896b3
1 Parent(s): 0c2389f

use real transformers lib and have changes locally

Browse files
image_processing_kosmos2_5.py CHANGED
@@ -16,7 +16,7 @@
16
 
17
  import math
18
  from typing import Dict, Optional, Union
19
-
20
  import numpy as np
21
 
22
  from transformers.image_processing_utils import BaseImageProcessor, BatchFeature
@@ -338,4 +338,6 @@ class Kosmos2_5ImageProcessor(BaseImageProcessor):
338
  tensor_type=return_tensors,
339
  )
340
 
341
- return encoded_outputs
 
 
 
16
 
17
  import math
18
  from typing import Dict, Optional, Union
19
+ from transformers import AutoImageProcessor
20
  import numpy as np
21
 
22
  from transformers.image_processing_utils import BaseImageProcessor, BatchFeature
 
338
  tensor_type=return_tensors,
339
  )
340
 
341
+ return encoded_outputs
342
+
343
+ AutoImageProcessor.register("Kosmos2_5ImageProcessor", Kosmos2_5ImageProcessor)
processing_kosmos2_5.py CHANGED
@@ -17,12 +17,13 @@ Processor class for Kosmos2_5.
17
  """
18
 
19
  from typing import List, Optional, Union
20
-
21
  from transformers.image_processing_utils import BatchFeature
22
  from transformers.processing_utils import ProcessorMixin
23
  from transformers.tokenization_utils_base import PaddingStrategy, TextInput, TruncationStrategy
24
  from transformers.utils import TensorType, is_torch_available
25
-
 
26
 
27
  if is_torch_available():
28
  import torch
@@ -49,7 +50,8 @@ class Kosmos2_5Processor(ProcessorMixin):
49
 
50
  def __init__(self, image_processor, tokenizer):
51
  tokenizer.return_token_type_ids = False
52
- super().__init__(image_processor, tokenizer)
 
53
 
54
  def __call__(
55
  self,
 
17
  """
18
 
19
  from typing import List, Optional, Union
20
+ import transformers
21
  from transformers.image_processing_utils import BatchFeature
22
  from transformers.processing_utils import ProcessorMixin
23
  from transformers.tokenization_utils_base import PaddingStrategy, TextInput, TruncationStrategy
24
  from transformers.utils import TensorType, is_torch_available
25
+ from .image_processing_kosmos2_5 import Kosmos2_5ImageProcessor
26
+ transformers.Kosmos2_5ImageProcessor = Kosmos2_5ImageProcessor
27
 
28
  if is_torch_available():
29
  import torch
 
50
 
51
  def __init__(self, image_processor, tokenizer):
52
  tokenizer.return_token_type_ids = False
53
+ self.image_processor = image_processor
54
+ self.tokenizer = tokenizer
55
 
56
  def __call__(
57
  self,
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<s>",
4
+ "lstrip": false,
5
+ "normalized": false,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "</s>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<pad>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<unk>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }