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