Spaces:
Sleeping
Sleeping
Commit
·
a665382
1
Parent(s):
20fa2d7
fix: wrong file name
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from apis.layoutlm import LayoutLM
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
layoutlm = None
|
| 7 |
+
|
| 8 |
+
def auth(username, password):
|
| 9 |
+
u = os.environ.get('USERNAME')
|
| 10 |
+
p = os.environ.get('PASSWORD')
|
| 11 |
+
return (username == u and password == p)
|
| 12 |
+
|
| 13 |
+
def inference(img) -> pd.DataFrame:
|
| 14 |
+
return layoutlm.inference(img)
|
| 15 |
+
|
| 16 |
+
if __name__ == "__main__":
|
| 17 |
+
try:
|
| 18 |
+
layoutlm = LayoutLM()
|
| 19 |
+
layoutlm.set_model(layoutlm.default_model)
|
| 20 |
+
|
| 21 |
+
demo = gr.Interface(
|
| 22 |
+
inference,
|
| 23 |
+
gr.Image(),
|
| 24 |
+
gr.Dataframe(
|
| 25 |
+
headers=['Data', 'Value'],
|
| 26 |
+
datatype=['str', 'str'],
|
| 27 |
+
row_count=8,
|
| 28 |
+
col_count=(2, 'fixed'),
|
| 29 |
+
interactive=False
|
| 30 |
+
)
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
demo.launch(auth=auth)
|
| 34 |
+
|
| 35 |
+
except Exception as e:
|
| 36 |
+
print(str(e))
|