Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
os.system('pip install transformers==4.25.1')
|
| 3 |
os.system('pip install sentencepiece')
|
| 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)
|
|
@@ -23,8 +24,9 @@ model = LayoutLMv2ForTokenClassification.from_pretrained("amir22010/layoutxlm-xf
|
|
| 23 |
# load image example
|
| 24 |
#dataset = load_dataset("ranpox/xfund", 'xfund.ja', split="validation")
|
| 25 |
#image = Image.open(dataset[0]["image"][0]).convert("RGB")
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 28 |
# define id2label, label2color
|
| 29 |
labels = [
|
| 30 |
'O',
|
|
@@ -93,8 +95,8 @@ css = ".output-image, .input-image {height: 40rem !important; width: 100% !impor
|
|
| 93 |
css = ".image-preview {height: auto !important;}"
|
| 94 |
|
| 95 |
iface = gr.Interface(fn=infer,
|
| 96 |
-
inputs=gr.Image(type="pil"),
|
| 97 |
-
outputs=gr.Image(type="pil", label="annotated image"),
|
| 98 |
title=title,
|
| 99 |
description=description,
|
| 100 |
article=article,
|
|
|
|
| 1 |
import os
|
| 2 |
+
os.system('pip install pyyaml==5.1')
|
| 3 |
os.system('pip install transformers==4.25.1')
|
| 4 |
os.system('pip install sentencepiece')
|
| 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)
|
|
|
|
| 24 |
# load image example
|
| 25 |
#dataset = load_dataset("ranpox/xfund", 'xfund.ja', split="validation")
|
| 26 |
#image = Image.open(dataset[0]["image"][0]).convert("RGB")
|
| 27 |
+
image1 = Image.open("./ja_val_49.jpg").convert("RGB")
|
| 28 |
+
image1.save("document.jpg")
|
| 29 |
+
|
| 30 |
# define id2label, label2color
|
| 31 |
labels = [
|
| 32 |
'O',
|
|
|
|
| 95 |
css = ".image-preview {height: auto !important;}"
|
| 96 |
|
| 97 |
iface = gr.Interface(fn=infer,
|
| 98 |
+
inputs=gr.inputs.Image(type="pil"),
|
| 99 |
+
outputs=gr.outputs.Image(type="pil", label="annotated image"),
|
| 100 |
title=title,
|
| 101 |
description=description,
|
| 102 |
article=article,
|