MohamedRashad commited on
Commit
8801de4
·
verified ·
1 Parent(s): 6d8361a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +6 -9
README.md CHANGED
@@ -21,18 +21,15 @@ Use the code below to get started with the model.
21
  ```python
22
  from PIL import Image
23
  import torch
24
- from transformers import (
25
- NougatProcessor,
26
- VisionEncoderDecoderModel,
27
- )
28
-
29
-
30
- processor = NougatProcessor.from_pretrained("MohamedRashad/arabic-small-nougat")
31
- model = VisionEncoderDecoderModel.from_pretrained("MohamedRashad/arabic-small-nougat")
32
 
 
 
 
33
  device = "cuda" if torch.cuda.is_available() else "cpu"
34
  model.to(device)
35
 
 
36
 
37
  def predict(image):
38
  # prepare PDF image for the model
@@ -43,7 +40,7 @@ def predict(image):
43
  outputs = model.generate(
44
  pixel_values.to(device),
45
  min_length=1,
46
- max_new_tokens=2048,
47
  bad_words_ids=[[processor.tokenizer.unk_token_id]],
48
  )
49
 
 
21
  ```python
22
  from PIL import Image
23
  import torch
24
+ from transformers import NougatProcessor, VisionEncoderDecoderModel
 
 
 
 
 
 
 
25
 
26
+ # Load the model and processor
27
+ processor = NougatProcessor.from_pretrained("facebook/nougat-small")
28
+ model = VisionEncoderDecoderModel.from_pretrained("arabic-small-nougat2")
29
  device = "cuda" if torch.cuda.is_available() else "cpu"
30
  model.to(device)
31
 
32
+ context_length = 2048
33
 
34
  def predict(image):
35
  # prepare PDF image for the model
 
40
  outputs = model.generate(
41
  pixel_values.to(device),
42
  min_length=1,
43
+ max_new_tokens=context_length,
44
  bad_words_ids=[[processor.tokenizer.unk_token_id]],
45
  )
46