Ammar-alhaj-ali commited on
Commit
a8358f8
1 Parent(s): a4d7a24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -1,24 +1,19 @@
1
  import os
2
  os.system('pip install git+https://github.com/huggingface/transformers.git --upgrade')
3
- os.system('pip install pyyaml==5.1')
4
  # workaround: install old version of pytorch since detectron2 hasn't released packages for pytorch 1.9 (issue: https://github.com/facebookresearch/detectron2/issues/3158)
5
  os.system('pip install torch==1.8.0+cu101 torchvision==0.9.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html')
6
 
7
- # install detectron2 that matches pytorch 1.8
8
- # See https://detectron2.readthedocs.io/tutorials/install.html for instructions
9
- os.system('pip install -q detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.8/index.html')
10
-
11
  ## install PyTesseract
12
  os.system('pip install -q pytesseract')
13
 
14
  import gradio as gr
15
  import numpy as np
16
- from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
17
  from datasets import load_dataset
18
  from PIL import Image, ImageDraw, ImageFont
19
 
20
- processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv2-base-uncased")
21
- model = LayoutLMv2ForTokenClassification.from_pretrained("nielsr/layoutlmv2-finetuned-funsd")
22
 
23
  # load image example
24
  dataset = load_dataset("nielsr/funsd", split="test")
 
1
  import os
2
  os.system('pip install git+https://github.com/huggingface/transformers.git --upgrade')
 
3
  # workaround: install old version of pytorch since detectron2 hasn't released packages for pytorch 1.9 (issue: https://github.com/facebookresearch/detectron2/issues/3158)
4
  os.system('pip install torch==1.8.0+cu101 torchvision==0.9.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html')
5
 
 
 
 
 
6
  ## install PyTesseract
7
  os.system('pip install -q pytesseract')
8
 
9
  import gradio as gr
10
  import numpy as np
11
+ from transformers import LayoutLMv3Processor, LayoutLMv3ForTokenClassification
12
  from datasets import load_dataset
13
  from PIL import Image, ImageDraw, ImageFont
14
 
15
+ processor = LayoutLMv2Processor.from_pretrained("microsoft/layoutlmv3-base-uncased")
16
+ model = LayoutLMv2ForTokenClassification.from_pretrained("nielsr/layoutlmv3-finetuned-funsd")
17
 
18
  # load image example
19
  dataset = load_dataset("nielsr/funsd", split="test")