estyle commited on
Commit
042d713
·
verified ·
1 Parent(s): 2e33681

Update after integration (#17)

Browse files

- update after integration (b9b6785fb4884bc79302d2710585c99675639794)
- update after integration (6d11b0db7c3041a2e01f09fb965e648f9df83b16)

Files changed (6) hide show
  1. config.json +3 -3
  2. md.py +2 -2
  3. ocr.py +2 -2
  4. special_tokens_map.json +33 -0
  5. tokenizer.json +0 -0
  6. tokenizer_config.json +0 -0
config.json CHANGED
@@ -82,8 +82,8 @@
82
  "bos_token_id": null,
83
  "chunk_size_feed_forward": 0,
84
  "cross_attention_hidden_size": null,
85
- "d_ff": 3968,
86
- "d_kv": 64,
87
  "decoder_start_token_id": null,
88
  "dense_act_fn": "gelu_new",
89
  "diversity_penalty": 0.0,
@@ -133,7 +133,7 @@
133
  "return_dict": true,
134
  "return_dict_in_generate": false,
135
  "sep_token_id": null,
136
- "seq_len": 4096,
137
  "suppress_tokens": null,
138
  "task_specific_params": null,
139
  "temperature": 1.0,
 
82
  "bos_token_id": null,
83
  "chunk_size_feed_forward": 0,
84
  "cross_attention_hidden_size": null,
85
+ "intermediate_size": 3968,
86
+ "head_dim": 64,
87
  "decoder_start_token_id": null,
88
  "dense_act_fn": "gelu_new",
89
  "diversity_penalty": 0.0,
 
133
  "return_dict": true,
134
  "return_dict_in_generate": false,
135
  "sep_token_id": null,
136
+ "max_num_patches": 4096,
137
  "suppress_tokens": null,
138
  "task_specific_params": null,
139
  "temperature": 1.0,
md.py CHANGED
@@ -11,7 +11,7 @@ model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=devic
11
  processor = AutoProcessor.from_pretrained(repo)
12
 
13
  # sample image
14
- url = "https://huggingface.co/microsoft/kosmos-2.5/blob/main/receipt_00008.png"
15
  image = Image.open(requests.get(url, stream=True).raw)
16
 
17
  prompt = "<md>"
@@ -30,4 +30,4 @@ generated_ids = model.generate(
30
  )
31
 
32
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
33
- print(generated_text[0])
 
11
  processor = AutoProcessor.from_pretrained(repo)
12
 
13
  # sample image
14
+ url = "https://huggingface.co/microsoft/kosmos-2.5/resolve/main/receipt_00008.png"
15
  image = Image.open(requests.get(url, stream=True).raw)
16
 
17
  prompt = "<md>"
 
30
  )
31
 
32
  generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)
33
+ print(generated_text[0])
ocr.py CHANGED
@@ -11,7 +11,7 @@ model = Kosmos2_5ForConditionalGeneration.from_pretrained(repo, device_map=devic
11
  processor = AutoProcessor.from_pretrained(repo)
12
 
13
  # sample image
14
- url = "https://huggingface.co/microsoft/kosmos-2.5/blob/main/receipt_00008.png"
15
  image = Image.open(requests.get(url, stream=True).raw)
16
 
17
  # bs = 1
@@ -70,4 +70,4 @@ for line in lines:
70
  continue
71
  line = list(map(int, line[:8]))
72
  draw.polygon(line, outline="red")
73
- image.save("output.png")
 
11
  processor = AutoProcessor.from_pretrained(repo)
12
 
13
  # sample image
14
+ url = "https://huggingface.co/microsoft/kosmos-2.5/resolve/main/receipt_00008.png"
15
  image = Image.open(requests.get(url, stream=True).raw)
16
 
17
  # bs = 1
 
70
  continue
71
  line = list(map(int, line[:8]))
72
  draw.polygon(line, outline="red")
73
+ image.save("output.png")
special_tokens_map.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "boi_token": "<image>",
3
+ "bos_token": {
4
+ "content": "<s>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ },
10
+ "eoi_token": "</image>",
11
+ "eos_token": {
12
+ "content": "</s>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false
17
+ },
18
+ "image_token": "<s>",
19
+ "pad_token": {
20
+ "content": "<pad>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "unk_token": {
27
+ "content": "<unk>",
28
+ "lstrip": false,
29
+ "normalized": false,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ }
33
+ }
tokenizer.json CHANGED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json CHANGED
The diff for this file is too large to render. See raw diff