Spaces:
Build error
Build error
Commit
·
0244e4b
1
Parent(s):
1031d26
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
# os.system('pip install gradio --upgrade')
|
| 3 |
-
# os.system('pip install git+https://github.com/huggingface/transformers.git --upgrade')
|
| 4 |
-
# os.system('pip install pyyaml==5.1')
|
| 5 |
-
# # workaround: install old version of pytorch since detectron2 hasn't released packages for pytorch 1.9 (issue: https://github.com/facebookresearch/detectron2/issues/3158)
|
| 6 |
-
# os.system('pip install torch==1.8.0+cu101 torchvision==0.9.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html')
|
| 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 |
-
# ## install PyTesseract
|
| 11 |
-
os.system('pip install -q pytesseract')
|
| 12 |
import gradio as gr
|
| 13 |
import numpy as np
|
| 14 |
from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
|
|
@@ -41,7 +31,7 @@ def unnormalize_box(bbox, width, height):
|
|
| 41 |
def iob_to_label(label):
|
| 42 |
label = label[2:]
|
| 43 |
if not label:
|
| 44 |
-
|
| 45 |
return label
|
| 46 |
|
| 47 |
|
|
|
|
| 1 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import numpy as np
|
| 4 |
from transformers import LayoutLMv2Processor, LayoutLMv2ForTokenClassification
|
|
|
|
| 31 |
def iob_to_label(label):
|
| 32 |
label = label[2:]
|
| 33 |
if not label:
|
| 34 |
+
return 'other'
|
| 35 |
return label
|
| 36 |
|
| 37 |
|